UNIX/ Reference Sheet

File Commands Process Management – concatenates and displays files /batch– execute commands at a later cat > – places standard input into file bg – lists stopped or background jobs; resume a – change current directory stopped job in the background – compares two files – clock daemon that executes commands at – copies a file or a directory specified dates and times – removes columns or fields from the specified crontab – modifies the user's crontab file, which is file(s) used by cron – displays line‐by‐line differences between two fg – brings the specified job to foreground text files pid – kill process id pid – displays the first lines of the specified file(s) killall proc – kill all processes named proc1 – joins two files – invoke a command with an altered scheduling jot – print sequential or random data priority hard or symbolic links to files – display your currently active processes -al – formatted listing with hidden files renice – alter priority of running processes ls – directory listing top – display all running processes dir – create a directory dir /less – output the contents of the specified File & Group Permissions file(s) in pages octal file – change the permissions of – rename or move a file file to octal, which can be found separately for – put line numbers on a file user, group, and world by adding: – sequentially copies each file to standard output, • 4 – read (r) displaying it according to the specified arguments; for • 2 – (w) example, in hexadecimal (often useful in conjunction • 1 – execute (x) with diff) Examples: – merge same lines of several files or chmod 777 – read, write, execute for all subsequent lines of one file chmod 755 – rwx for owner, rx for group and world pr – produces a printed listing of one or more files For more options, see man chmod. suitable for printing – change the group‐ID of the specified files or – print current working directory directories – remove the specified file(s); using the -rf flag groups – show group memberships 1 allows a directory to be removed Searching – sort, merge or sequence check text files – search for a pattern in the specified files – split a file into pieces command | grep pattern – search for pattern – displays the last lines of the specified file(s) in the output of command tail -f file – output the contents of file as it file – find all instances of file (UNIX) grows, starting with the last 10 lines locate file – find all instances of file – change file access and modification times; ‐ construct argument lists and invoke utility can be used to create a new 0‐byte (empty) file – translate characters from one string to another Compression – report or filter out repeated lines in a file You can find a number of compression and – display a count of lines, words and characters in decompression utilities. Check the man pages for tar, a file compress/uncompress, gzip/gunzip and SSH & Secure File Copying zip/unzip. Others are also available. scp – copies files between hosts on a network tar cf file.tar files – create a tar named sftp – an interactive file transfer program file.tar containing files ssh user@host – connect to host as user tar xf file.tar – extract the files from ssh-copy-id user@host – add your key to file.tar host for user to enable a keyed or passwordless gzip file – compresses file and renames it to login file.gz

gunzip file.gz – decompresses file.gz back to file

1 Use with extreme caution! UNIX/LINUX Command Reference Sheet

Version Control .snapshot – (CSCF/MFCF only) A backup system is See the manual pages for cvs, svn or rcs. in place in the student.math and student.cs environments where hourly, daily, weekly and System Information monthly backups are made. See absolute – (CSCF/MFCF only) convert file names to http://webtest.mfcf.uwaterloo.ca/wiki/index.php/ Snapshots absolute path names – create a pseudonym for a command or absolute `which app` – (CSCF/MFCF only) series of commands show the full path to the app that will be run by apropos – locate commands by keyword lookup default clear – clear the terminal screen, if possible – show this month's calendar dos2unix – convert text file from DOS format to ISO chfn – change the user's finger information format date – show the current date and time init_home – (CSCF/MFCF only) reinitialize your diskquota – (CSCF/MFCF only) display the user's home directory disk quota ispell – interactive spelling checking – show disk usage of each file , recursively lock – lock a terminal when you are away finger user – display information about user man ascii – displays the map of the ASCII history – displays the list of recently entered character set commands oed – look things up in the Oxford English Dictionary hostselect – consult a configuration file to return script – makes a typescript of everything printed an optimal host name based upon the specified on your terminal. attribute scriptfix – clean up script output files lpr – submit a print request spell – outputs words from the named documents lpq – display the contents of a print queue that are not in the spelling list nor derivable from man command – show the manual for command words in the spelling list – permit or deny messages unalias – remove a pseudonym for a command or passwd – change the user's password series of commands ruptime – show current uptime of other hosts unix2dos – convert text file from ISO format to -a – show kernel information DOS format uptime – show current uptime xlock – locks the local X display until a password is – display is online w entered whereis app – show possible locations of app which app – show which app will be run by default Shortcuts whoami – who you are logged in as Ctrl+C – halts the current command Ctrl+Z – stops the current command, resume with Compilation & Debugging fg in the foreground or bg in the background ddd – graphical front end to gdb Ctrl+D – log out of current session, similar to gcc – GNU project C and C++ compiler ; used to signal end‐of‐file when running an – front‐end to to explicitly compile C++ code g++ gcc application that reads from standard input gdb – GNU debugger Ctrl+W – erases one word in the current line gmake – GNU version of make Ctrl+U – erases the whole line make – utility to maintain groups of programs Ctrl+R – to bring up a recent command xxgdb – graphical front end to gdb; exists on cpu- ^pre1^pre2 – repeats the last command with linux leading text pre1 replaced with pre2 Generally Useful Tools !:gs/pre1/pre2– repeats the last command with MFCF FAQ ‐ located at all occurrences of text pre1 replaced with pre2 http://webtest.mfcf.uwaterloo.ca/wiki/index.php/ !! ‐ repeats the last command MFCF_FAQ !com – repeats the most recent command entered that http://www.cs.uwaterloo.ca/cscf/student/hosts – can be uniquely identified as starting with com a list of the servers available in the undergraduate !num – repeats the command numbered num environment, highlighting the round‐robin server exit – log out of current session names (recommended for access to a particular server type)