typing this (if you're on a Mac) | or this (if you run Windows) | does this |
---|---|---|
cd / | cd / | takes you to the root directory |
cd ~ | no direct shortcut | takes you to your home directory |
cd .. | cd .. | takes you up one level in your file directory |
cd ../../ | cd ../../ | takes you up two levels in your file directory |
cd path/to/some/folder | cd path/to/some/folder | take you to some folder on your computer |
tar -xvzf [fileName.tar.gz] | tar -xvzf [fileName.tar.gz] | unzip a .tar file |
gzip [filename] | gzip [filename] | Compresses a file to be filename.gz |
ls and ls -l and ls -a | ls and ls -l and ls -a or dir | list all files and folders in your working diretory with info on permissions. -a option shows hidden files |
ls -l | wc -l | ls -l | wc -l | counts files in a directory |
mv [fileName or folderName] [directory] | mv [fileName or folderName] [directory] | Moves a file or folder to a new location. Important, if the new location doesn't exist then mv renames your file to the destination name |
du -a -h | sort -hr | no direct shortcut | lists all files and folders in your working directory sorted by size |
du -sh * | du -sh * | simpler version of the command above. lists all files in a folder and shows their file size |
df -h | df -h | view free/used disk space by drive |
tree -d | tree -d | lists all files and folders in your working directory as a tree structure |
lsblk | no direct shortcut | lists drives and their size (as well as used/free space on each) |
pressing up arrow | pressing up arrow | recalls previous command |
chmod ### [fileName] | chmod ### [fileName] | edits permissions on file. See graphic below for the appropriate numbers to use in place of ### |
chown [yourUserName] [fileName] | chown [yourUserName] [fileName] | makes you the owner of a file |
chgrp [yourUserName] [fileName] | chgrp [yourUserName] [fileName] | assigns you as the group for the file |
rm -rf [directoryName] | rm -rf [directoryName] | removes a folder and all of its contents |
wget [URLtoFile] | no direct shortcut | downloads a file from the web |
nano [file.txt] | nano [file.txt] | opens up a text file in a text editor directly in your Bash application |
export PATH="/path/to/your/software/:$PATH" | no direct shortcut | add a new piece of software to the system PATH so it is executable from anywhere |
alias something="something else" | doskey something=something else | add lines like this to your ~/.bash_profile to create a keyboard shortcut, in this case typing 'something' actually does 'something else' |