V0.3 (April 2009) -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 Display environment vars xvf filename.tar Unarchive Display information env eth0 ifconfig about eth0 interface. $PATH Display path where cvfz filename.tgz files Arch+Compress tar eth0 up Brings up eth0. commands are located. xvfz filename.tgz Uncompress eth0 1.1.1.1 Give a static IP to eth0. $HOME Location of the home dir bzip2 files Compress $SHELL Shell in use -n List all routes. bunzip2 finaname.bz2 Decompress $LD_LIBRARY Directory with dynamic Send a packet to hostname _PATH shared libraries. zip files filename.zip Compress ping hostname machine. $DISPLAY To display applications unzip filename.zip Decompress List all open ports and should be sent netstat -a conections in and out of the machine. newalias=cmd Set a new alias List process that is -i:80 locale Show language settings lsof listening in port 80. Where alias and Redirection Establish a secure shell ~/.bashrc ssh server ~/.bash_profile environment vars can be to server stored to persist Redirect input (stdin), errors (stderr) and output (stdout) between files and applications. Copy to remote scp file [email protected]:/ location “/” in server 1.1.1.1 as “user”. echo msg > file1 Redirect stdout to file1 Configuring the system echo msg 2> file1 Redirect stderr to file1 myprog &> file1 Redirect both stdout and Session Command line applications provided by distributions to stderr to file configure the system. Useful shortcuts and commands for advanced session Redirect file1 content into Mandriva, Caixa Mágica myprog < file1 management. drakconf stdin of myprog d from the command line. (?) Debian, Ubuntu echo msg | myprog Redirect stdout to myprog s Freezes stdout. (?) Fedora Control + q Unfreezes stdout. yast2 (?) OpenSuSE Look backward in command r history Complete the prompt with the Locating files Up last matching command in Page history Files and directories Commands for managing files and directories. Down The next matching command. Commands for managing files and directories whereis command Where in $PATH is Launch screen. -al List files command screen (Ctrl-A d) Dettach session. file1 dir2/ Copy file to directory dir2/ locate -i file Locate file in disk (-i = not case sensitive). Requires -r Reattach a previous session. file1 dir2/ Move file / rename file updatedb before. file1 Show content of a text file1 updatedb Updates the database of existent files and directories. Help file1 Delete file1 / -name file Finds recursively starting in If none of the above works for you, try this. dir Create directory location “/” the file with the given name. man command Get information about dir Change into directory command. . -exec ls {} \; Executes command “ls” over find each entry of find result 1 command Get section 1 of command . -k string List all commands with System status & Users “string” in the description . Parsing Get information about system and manage users. info command Display documentation in info format for command. -aux List processes. Commands for parsing files and messages. pstree List processes as a . Prints line where pattern pattern file processes by CPU (or occur in file. RAM). -E ext_regexp file Use extend regexp. Check free memory and swap. free -P Perl_regexp file Use Perl regexp. Print field 2 of each line of Get updates of this Linux command-line Cheat -h Show disk space in active '{print $2}' file partitions. file (space separated). Sheet in: http://paulotrezentos.polo-sul.org/cheatsheet/ vmstat -d Display virtual memory, CPU Sends to stdout the and IO statistics s/str1/str2 file1 content of file1 replacing str1 by str2. [email protected] -a Show info about Kernel & hw. [email protected] useradd -m user Add an user, copy skel. This cheat sheet is under: userdel user Delete an user.