Linux Help
Below is a summary of many commonly used Linux commands. There are several excellent tutorials and tools available online. Below is a list that we have compiled:
Linux Reference Material
Linux Training
Linux Basics
Linux Command Info
Linux Wikis
Linux Command References
File Commands
ls– directory listingls -al– formatted listing with hidden filescd dir– change directory todirpwd– show current directory (Print Working Directory)mkdir dir– create a directorydirrm file– delete filerm -r dir– delete directorydirand all its contentsrm -f file– force delete filerm -rf dir– force delete directorydirand all its contents (use with caution)cp file1 file2– copyfile1tofile2(overwritesfile2if it exists)cp -r dir1 dir2– copydir1todir2; createdir2if it doesn’t existmv file1 file2– renamefile1tofile2(overwritesfile2if it exists)mv file dir– movefileinto directorydirln -s file_or_dir link– create a symbolic linklinkpointing tofile_or_dirtouch file– create emptyfile; iffileexists, updates last-modified dateless file– view contents offilehead file– output first 10 lines offiletail file– output last 10 lines offiletail -f file– output contents offileas it grows, starting with last 10 lines
Process Management
ps– display your currnet active processestop– display all running processeskill pid– kill process idpid(numerical ID)bg– lists stopped or background jobs; resume a stopped job in the backgroundfg– brings the most recent job to the foregroundfg n– brings jobnto the foreground
File Permissions
chmod mode file– change permissions offileto givenmode; mode can be[ugoa...][[+-=][perms...]...]u, g, o, a– specify the owner:user,group,other, orall+, -, =–+adds given permissions to file,-removes given permissions from file,=sets given permissions on fileperms : r, w, xor any combination of the three –rmeans read permission,wmeans write permission,xmeans execute (file) or cd (directory) permission
Searching Within Files
These commands can be used to find content within files:
grep pattern files– print out lines containingpatterninfilesgrep -r pattern dir– print out lines containingpatternin all files found recursively descending into directorydircommand | grep pattern– print out lines from the output ofcommandwhich containpattern
System Info
date– show current date and timecal– show this month’s calendarcal year– show calendar for entireyearuptime– show how long the machine has been upw– display users who are logged inwhoami– who you are logged in asid– print all user ID information for yourselffinger user- display information aboutuseruname -a– show information about machinecat /proc/cpuinfo– cpu informationcat /proc/meminfo– memory informationman command– show manual forcommanddf -h– show disk usagefree– show memory and swap usagewhereis command– show possible paths tocommandwhich command– show absolute path tocommand
Compression
tar cf dir.tar dir– create a tar file named dir.tar containing all files in the directory dirtar xf dir.tar– extract all files from dir.tartar zcf dir.tar.gz dir– create a gzipped tar file named dir.tar.gz containing all files in dirtar zxf dir.tar.gz– extract all files from dir.tar.gztar jcf dir.tar.bz2 dir– create a tar file named dir.tar.bz2 compressed with bzip2 containing all files in dirtar jxf dir.tar.bz2– extract all files from dir.tar.bz2gzip file– compress file and rename it file.gzgzip -d file.gz– uncompress file.gz into file
Internet and Network
jwhois domain– print administrative and contact information for the owner of domaindig domain– print DNS information for domaindig -x host– print reverse DNS lookup of hostwget url– download the file at urlwget -c url– resume a stopped download
Package Installation from Source
Typical GNU-style source packages for software follow this recipe for building:
$ ./configure --prefix=$HOME/dir
$ make
$ make install
You can also read our in-depth guide to compiling software on DEAC, for software packages that require considerably more work than this.
Other Useful Commands
Ctrl-C– halts the current command (send signalSIGINT)Ctrl-Z– pauses the current commandfg– resumes aCtrl-Z’ed commandbg– resumes aCtrl-Z’ed command into the background (returning terminal control)!!– repeats the last commandUp and Down keys on your keyboard – browse command history