A few basic shell (bash, zsh, ...) commands for UNIX (Linux, MacOS) CLI (command-line interface)
# change directory to /home/username/Downloads:
$ cd /home/username/Downloads
# first, go to some directory
$ cd /home/valosek/Downloads
# then check its path
$ pwd
/home/valosek/Downloads
Note - echo $PWD returns same output as the pwd command
# make a new directory with name test_folder
$ mkdir test_folder
# check what is inside current directory
$ ls
# check what is inside given directory
$ ls test_folder
# check what is inside /home/username/Downloads directory
$ ls /home/username/Downloads
useful options for ls command:
ls -l - list view
ls -t - sorted by time
ls -a - show hidden files
ls -h - human readable form
ls -lath - all options together
ls -d - check folder itself (do not check what is inside)
# copy two files (my_file and my_file2) to /home/username/Downloads folder
$ cp my_file my_file2 /home/username/Downloads
# copy two folders (my_folder and my_folder2) to /home/username/Downloads folder
$ cp -r my_folder my_folder2 /home/username/Downloads
# first, create some directory
$ mkdir test_folder
# rename directory test_folder to test_folder_2
$ mv test_folder test_folder_2
# first, create some directory
$ mkdir test_folder
# remove directory test_folder
$ rm -r test_folder
$ nano my_file.txt
useful shortcuts for nano command:
ctrl + W - find
ctrl + O - save
ctrl + X - exit
# gedit - simple graphical text editor built-in in GNOME
$ gedit my_file.txt
# atom - advanced graphical text editor - https://atom.io/
$ atom my_file.txt
$ cat my_file.txt
$ head my_file.txt
Note - you can specify number of lines to print, e.g., head -20 my_file.txt
$ tail my_file.txt
Note - you can specify number of lines to print, e.g., tail -20 my_file.txt
$ find $PWD -name 'some_file_name' -type f
useful options for find command:
-name filename - filename - name of file or directory (wildcards such as * can be used)
-type f/d - f - file, d - directory
-user usr - usr - owner of files
$ grep "my_string" my_file.txt
# start a new VNC session with certain display number (e.g., 5) and certain screen resolution
$ vncserver :5 -geometry 1650x1100
# OR
$ vncserver :5 -geometry 1650x1100 -localhost no
# OR
$ vncserver :5 -xstartup ~/.vnc/xstartup -localhost 0
# kill certain VNC server
$ vncserver -kill :5
# connect to the VNC server
$ vncviewer :5
Note - if you get warning that VNC session is already running under certain display number, specify another free display number
Tip - vncserver can be configurated by ~/.vnc/xstartup file, e.g., my xstartup file for mate enviroment and zsh shell looks:
#!/bin/sh
unset DBUS_SESSION_BUS_ADDRESS
unset SESSION_MANAGER
export SHELL=/bin/zsh
exec /usr/bin/mate-session
chmod a+x ~/.vnc/xstartup
$ aeskulap folder_with_dicom_images/*
$ fsleyes my_brain.nii.gz