3 (April 2009)
Linux command-line
Cheat Sheet
Environment Network
Compress and archive
Verify and set the environment variables in BASH. Miscellaneous commands for networking.
Useful tools for compressing and archive files.
export VAR=content Store the variable with
content cvf filename.tar files Archive List all active interfaces
tar
env Display environment vars xvf filename.tar Unarchive Display information
eth0
ifconfig about eth0 interface.
echo $PATH Display path where cvfz filename.tgz files Arch+Compress
commands are located. tar eth0 up Brings up eth0.
xvfz filename.tgz Uncompress
$HOME Location of the home dir eth0 1.1.1.1 Give a static IP to eth0.
bzip2 files Compress
$SHELL Shell in use route -n List all routes.
bunzip2 finaname.bz2 Decompress
$LD_LIBRARY Directory with dynamic Send a packet to
_PATH shared libraries. zip files filename.zip Compress ping hostname
hostname machine.
$DISPLAY To which display applications unzip filename.zip Decompress List all open ports and
should be sent netstat -a conections in and out
of the machine.
alias newalias=cmd Set a new alias
List process that is
locale Show language settings lsof -i:80
listening in port 80.
Configuring the system echo msg 2> file1 Redirect stderr to file1
cat file1 Show content of a text file1 updatedb Updates the database of
existent files and directories. Help
rm file1 Delete file1
/ -name file Finds recursively starting in
If none of the above works for you, try this.
mkdir dir Create directory find location “/” the file with the
given name. man command Get information about
cd dir Change into directory command.
. -exec ls {} \; Executes command “ls” over
find each entry of find result 1 command Get section 1 of command
man page.
-k string List all commands with
System status & Users “string” in the description .
df -h Show disk space in active Print field 2 of each line of Get updates of this Linux command-line Cheat
awk '{print $2}' file
file (space separated). Sheet in:
partitions.
http://paulotrezentos.polo-sul.org/cheatsheet/
vmstat -d Display virtual memory, CPU Sends to stdout the
and IO statistics sed s/str1/str2 file1 content of file1 replacing
str1 by str2. Paulo.Trezentos@iscte.pt
uname -a Show info about Kernel & hw. Paulo.Trezentos@caixamagica.pt
useradd -m user Add an user, copy skel. This cheat sheet is under: