UNIX/LINUX Command Reference Sheet
Total Page:16
File Type:pdf, Size:1020Kb
UNIX/LINUX Command Reference Sheet File Commands Process Management cat – concatenates and displays files at/batch– execute commands at a later time cat > file – places standard input into file bg – lists stopped or background jobs; resume a cd – change current directory stopped job in the background cmp – compares two files cron – clock daemon that executes commands at cp – copies a file or a directory specified dates and times cut – removes columns or fields from the specified crontab – modifies the user's crontab file, which is file(s) used by cron diff – displays line‐by‐line differences between two fg – brings the specified job to foreground text files kill pid – kill process id pid head – displays the first lines of the specified file(s) killall proc – kill all processes named proc1 join – joins two files nice – invoke a command with an altered scheduling jot – print sequential or random data priority ln – make hard or symbolic links to files ps – display your currently active processes ls -al – formatted listing with hidden files renice – alter priority of running processes ls – directory listing top – display all running processes mkdir dir – create a directory dir more/less – output the contents of the specified File & Group Permissions file(s) in pages chmod octal file – change the permissions of mv – rename or move a file file to octal, which can be found separately for nl – put line numbers on a file user, group, and world by adding: od – sequentially copies each file to standard output, • 4 – read (r) displaying it according to the specified arguments; for • 2 – write (w) example, in hexadecimal (often useful in conjunction • 1 – execute (x) with diff) Examples: paste – 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 chgrp – change the group‐ID of the specified files or pwd – print current working directory directories rm – remove the specified file(s); using the -rf flag groups – show group memberships 1 allows a directory to be removed Searching sort – sort, merge or sequence check text files grep – search for a pattern in the specified files split – split a file into pieces command | grep pattern – search for pattern tail – displays the last lines of the specified file(s) in the output of command tail -f file – output the contents of file as it find file – find all instances of file (UNIX) grows, starting with the last 10 lines locate file – find all instances of file touch – change file access and modification times; xargs ‐ construct argument lists and invoke utility can be used to create a new 0‐byte (empty) file tr – translate characters from one string to another Compression uniq – report or filter out repeated lines in a file You can find a number of compression and wc – 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 alias – 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 cal – 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 du – 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 mesg – 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 uname -a – show kernel information DOS format uptime – show current uptime xlock – locks the local X display until a password is – display who 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 exit; 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 – type 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) .