************************************** Basic commands in terminal computing ************************************** In here, we want to demonstrate basic commands when doing work in the powershell/terminal as well as in the jupyter notebook. NOTE, that when running terminal commands in the jupyter notebook, you need to add a :code:`!` in front of the command, so e.g. :code:`!ls`. File and Directory Management ============================= * :code:`ls` - shows the content of your current directory. :: ls ls -l # Detailed list (long format) ls -a # Show hidden files * :code:`cd` - Change directory. :: cd /path/to/directory cd ~ # Go to home directory cd .. # Go up one directory level * :code:`pwd` - Print working directory (shows your current directory). :: pwd * :code:`mkdir` - Create a new directory. :: mkdir new_directory * :code:`rmdir` - Remove an empty directory. :: rmdir directory_name * :code:`cp` - Copy files or directories. :: cp source_file destination_file cp -r source_directory destination_directory # Recursive copy (for directories) * :code:`mv` - Move or rename files or directories. :: mv old_name new_name mv file /new/location * :code:`rm` - Remove files or directories. :: rm file_name rm -r directory_name # Recursive remove (for directories) rm -f file_name # Force removal (use with caution) File Viewing and Editing ======================== * :code:`cat` - Display the contents of a file. :: cat file_name * :code:`less` - View file contents one page at a time. :: less file_name * :code:`touch`` - Create an empty file or update the timestamp of an existing file. :: touch file_name * :code:`tail` - Showes the last lines of a file :: tail file_name tail -n N file_name #shows the last N lines of the file Search and Find =============== * :code:`grep` - Search inside files. :: grep "search_term" file_name grep -r "search_term" directory # Recursive search * :code:`find` - Search for files and directories. :: find /path -name "file_name" Compression and Archiving ========================= * :code:`tar` - Archive or extract files. :: tar -cvf archive_name.tar directory_name # Create a tar archive tar -xvf archive_name.tar # Extract a tar archive tar -czvf archive_name.tar.gz directory_name # Create a gzip-compressed tar archive tar -xzvf archive_name.tar.gz # Extract a gzip-compressed tar archive