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
SSH
version for repositories YOU’ll be updating and theHTTP
version 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 -rf
command takes care of the deletion if not)
- E.g.,
mv f1 f2
- Cut and paste or rename -f1
is the original file/directory andf2
is the new name of the file/directory- Examples (assuming we have
~/file1
,~/file2
,~/dir1
,~/dir1/dir2
mv file1 file2
(renamesfile1
tofile2
)mv ~/file1 ~/dir1/my_new_file
(moves and renamesfile1
to bemy_new_file
withindir1
)mv dir1 my_new_dir
(renamesdir1
to 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/dir2
cp file1 new_file
(copiesfile1
tonew_file
)cp -r dir1 newdir
(recursively copiesdir1
tonewdir
- meaning all the contents ofdir1
are 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
command1
intocommand2
- Send output of
command1 > file
- Send output of
command
into a new file:file
- Send output of
command1 > file 2> file.err
- Send output of
command
into 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