LINUX CHEAT SHEET - AGUIRRE LAB

The following is a list of useful commands for use in your Linux terminal.

wget https://raw.githubusercontent.com/aguirrelab/Geo_Morph_Evolution_Lab/main/0_stickleback_evol_lab_data.TPS


"tab" man command
Clicking the "tab" key autocompletes file names (do not type tab, use tab key) Show the manual for a command/program


help --help
Lists help for shell builtins (e.g., help cd) Shows usage (syntax and options) information for commands


ls ls -ltrh
See what is in your folder Long view(l) ordered by time (t) in reverse order with most recent last (r), human readible (h), of what is in your folder


ls -a clear
Lists all folder content Clear screen


pwd mkdir
Prints your working directory so you can see where you are Make a directory in the folder (directory) you are in


cd cd ..
Change directory Go to the directory above where you are


cp file1 file2 cp file1 ~/dir2/
Copy file1 to file2. If file 2 exists, it will be overwritten. use -i to make command interactive, -r to copy files recusively (required for copying directories), -v for verbose, display messages as files are copied. Copy file1 into a different directory (directory2 in this case)


mv -i file1 file2 mv dir1 dir2
Move file1 to file2 prompting for confirmation if file2 already exists. file2 is overwritten if it exists. file1 ceases to exist in either case. Moves directory 1 into directory 2.


rm rm -rf
Remove a file. For example: rm example_dummy_file.txt (will delete example_dummy_file.txt) Remove a directory with all files and subdirectories in it. For example: rm -rf bad_directory/ (will delete the directory "bad_directory" and everything in it)


less head
To see the first 10 lines of a file. For example: less dummy_file.txt To see the first 10 lines of a file without it disappearing. For example: head dummy_file.txt


wc -l wc -l <
Finds the number of lines in a file. For example: wc -l dummy_file.txt will give the output 10 dummy_file.txt (there are 10 lines in that file). Counts the lines in a file but only outputs the number of lines. For example, wc -l < dummy_file.txt will give the output as 10.


nano vim
To edit scripts you can use the nano text editor. For example: nano dummy_file.txt (This opens a text editor in which you can modify the script.) To edit scripts you can also use the vim text editor. It is slightly more advanced and faster than nano. For example: vim dummy_file.txt (This opens a text editor in which you can modify the script.) To quit, type :q or :q! to quit without saving changes.


$ top $ htop
Check on the progress of an application in your terminal Graphical view of application progress


zip tar
Zip files or folders. To zip one or more folders, use the command zip -r output_file_name folder_1 folder_2 ... folder_n. For example, to zip a folder called Downloads, use the command: zip -r Downloads.zip Downloads. Extracts zip files. For example: tar -xvzf GBSgenotypes.tar.gz. -xvzf refers to various options and GBSgenotypes.tar.gz is the zipped file or folder.


wget touch
downloads files from the web into the directory that you are in. For example: wget https://raw.githubusercontent.com /aguirrelab/Geo_Morph_Evolution_Lab /main/0_stickleback_evol_lab_data.TPS Creates a new file. For example: touch dummy_file.txt (This creates a blank file that you can open and edit in the nano text editor).


exit sudo
To exit the root Run commands as the root user. Allows you to install new applications or make changes requiring permission


Last Updated: June 6, 2022