This page lists the commands that you should be practicing. I will do my best to keep this list updated as we go through things in class.
Connecting
ssh- connect to remove serverssh username@server_address- E.g.,
ssh yourusername@eos01.cis.gvsu.edu
Getting files/directories
wget <URL>- gets a file from a remote URLgit clone <REPO>- clones a git repository- Note - typically you’ll want to use the
SSHversion for repositories YOU’ll be updating and theHTTPversion for repositories you just want to play with
- Note - typically you’ll want to use the
Special file paths
.- current working directory..- parent directory (go up a level)~- shortcut to your home directory/- root of file system/home/yourusername- your home directory
File systems
ls- List files- E.g.,
ls ~,ls .,ls CIS241
- E.g.,
cd- Change directory- E.g.,
cd ~,cd ..,cd /WEB_STUDENT/yourusername
- E.g.,
touch filename- Create empty filerm- Remove – BE CAREFUL - THERE IS NO RECYCLE BIN AND ANYTHING DELETED CANNOT BE RECOVERED- E.g.,
rm filename- deletes filename rm -rf directory- removes the directory AND everything inside of it
- E.g.,
rmdir- Remove directory- E.g.,
rmdir directory- note, directory must be empty for this to work (therm -rfcommand takes care of the deletion if not)
- E.g.,
mv f1 f2- Cut and paste or rename -f1is the original file/directory andf2is the new name of the file/directory- Examples (assuming we have
~/file1,~/file2,~/dir1,~/dir1/dir2mv file1 file2(renamesfile1tofile2)mv ~/file1 ~/dir1/my_new_file(moves and renamesfile1to bemy_new_filewithindir1)mv dir1 my_new_dir(renamesdir1to bemy_new_dir)
- Examples (assuming we have
cp f1 f2- Copy and paste (same concept asmv, but creates a copy)- Examples (assuming we have
~/file1,~/file2,~/dir1,~/dir1/dir2cp file1 new_file(copiesfile1tonew_file)cp -r dir1 newdir(recursively copiesdir1tonewdir- meaning all the contents ofdir1are also now innewdir)
- Examples (assuming we have
tree- shows a tree-based graphical representation of your current working directory and its childrentree <path>- same, but for the<path>provided
pwd- tells you where you are at in the filesystem
Viewing Files
cat <filename>- dumps contents of file to terminal
Editing
nano <filename>- edit a file with the nano editor^in the bottom menu represents Ctrl (or Cmd if you’re on Mac)
Piping and Redirecting
command1 | command2- Send output of
command1intocommand2
- Send output of
command1 > file- Send output of
commandinto a new file:file
- Send output of
command1 > file 2> file.err- Send output of
commandinto a new file (file) and error into a new file (file.err)
- Send output of
File Manipulation
Worth checking the man pages for parameters!
wc- Count lines, words, and bytes in a file
cut- Get columns in a delimited file or character offsets per line
tr- Replaces characters with a specified pattern
diff- Compares two files