1. Text Editor

a. vi / vim

usage: vim [arguments] [file ..] edit specified file(s)
or: vim [arguments] – read text from stdin
or: vim [arguments] -t tag edit file where tag is defined

Arguments:
— Only file names after this
-v Vi mode (like “vi”)
-e Ex mode (like “ex”)
-E Improved Ex mode
-s Silent (batch) mode (only for “ex”)
-y Easy mode (like “evim”, modeless)
-R Readonly mode (like “view”)
-Z Restricted mode (like “rvim”)
-m Modifications (writing files) not allowed
-M Modifications in text not allowed
-b Binary mode
-C Compatible with Vi: ‘compatible’
-N Not fully Vi compatible: ‘nocompatible’
-V[N][fname] Be verbose [level N] [log messages to fname]
-n No swap file, use memory only
-r List swap files and exit
-r (with file name)Recover crashed session
-L Same as -r
-T Set terminal type to
-u Use instead of any .vimrc
–noplugin Don’t load plugin scripts
-p[N] Open N tab pages (default: one for each file)
-o[N] Open N windows (default: one for each file)
-O[N] Like -o but split vertically
+ Start at end of file
+ Start at line
–cmd Execute before loading any vimrc file
-c Execute after loading the first file
-S Source file after loading the first file
-s Read Normal mode commands from file
-w Append all typed commands to file
-W Write all typed commands to file
-h or –help Print Help (this message) and exit
–version Print version information and exit

b. nano

Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]…
Option GNU long option Meaning
+LINE,COLUMN Start at line LINE, column COLUMN
-A –smarthome  Enable smart home key
-B –backup       Save backups of existing files
-C- -backupdir   Directory for saving unique backup files
-D –boldtext Use bold instead of reverse video text
-E –tabstospaces Convert typed tabs to spaces
-F –multibuffer Read a file into a new buffer by default
-G –locking Use (vim-style) lock files
-H –historylog Log & read search/replace string history
-I –ignorercfiles Don’t look at nanorc files
-K –rebindkeypad Fix numeric keypad key confusion problem
-L –nonewlines Don’t add newlines to the ends of files
-N –noconvert Don’t convert files from DOS/Mac format
-O –morespace Use one more line for editing
-P –poslog Log & read location of cursor position
-Q –quotestr= Quoting string
-R –restricted Restricted mode
-S –smooth Scroll by line instead of half-screen
-T <#cols> –tabsize=<#cols> Set width of a tab to #cols columns
-U –quickblank Do quick statusbar blanking
-V –version Print version information and exit
-W –wordbounds Detect word boundaries more accurately
-Y –syntax= Syntax definition to use for coloring
-c –const Constantly show cursor position
-d –rebinddelete Fix Backspace/Delete confusion problem
-h –help Show this help text
-i –autoindent Automatically indent new lines
-k –cut Cut from cursor to end of line
-l –nofollow Don’t follow symbolic links, overwrite
-m –mouse Enable the use of the mouse
-n –noread Do not read the file (only write it)
-o –operatingdir Set operating directory
-p –preserve Preserve XON (^Q) and XOFF (^S) keys
-q –quiet Silently ignore startup issues like rc file errors
-r <#cols>–fill=<#cols> Set hard-wrapping point at column #cols
-s –speller= Enable alternate speller
-t –tempfile Auto save on exit, don’t prompt
-v –view View mode (read-only)
-w –nowrap Don’t hard-wrap long lines
-x –nohelp Don’t show the two help lines
-z –suspend Enable suspension
-$ –softwrap Enable soft line wrapping

2. Directory related

chdir Change working directory
cd to navigate into directories
chkconfig Tool for maintaining the /etc/rc[0-6].d directory hierarchy
chmod Change the access permissions of files and directories
chroot Change root directory
cp to copy a empty directory
cp –r to copy a whole directory along with contents inside it
dir Briefly list directory contents
dircolors Colour setup for `ls’
dirname Convert a full pathname to just a path
ls list of all the items inside of our current directory
ls -al long detail listing of all the items inside of our current directory
mkdir Create new folder(s)
mv Move or rename directories
pwd Print Working Directory
rmdir to remove a empty directory
rm -r to remove a directory along with everything present inside it
vdir Verbosely list directory contents (`ls -l -b’)

3. File Related

awk Find and Replace text within file(s)
cat Concatenate files and print on the standard output
chgrp Change the group ownership of files
chmod Change the access permissions of files and directories
cmp Compare two files
comm Compare two sorted files line by line
cp Copy one or more files to another location
csplit Split a file into context-determined pieces
cut Divide a file into several parts
dd Data Dump – Convert and copy a file
diff Display the differences between two files
diff3 Show differences among three files
egrep Search file(s) for lines that match an extended expression
fgrep Search file(s) for lines that match a fixed string
find Search for files that meet a desired criteria
fsck Filesystem consistency check and repair
gawk Find and Replace text within file(s)
grep Search file(s) for lines that match a given pattern
gzip Compress or decompress named file(s)
head Output the first part of file(s)
install Copy files and set attributes
ln Make links between files
ls List information about file(s)
mknod Make block or character special files
mv Move or rename files or directories
nl Number lines and write files
paste Merge lines of files
pathchk Check file name portability
pr Convert text files for printing
rcp Copy files between two machines
rm Remove files
rsync Remote file copy (Synchronize file trees)
sdiff Merge two files interactively
sort Sort text files
split Split a file into fixed-size pieces
sum Print a checksum for a file
symlink Make a new name for a file
tee Redirect output to multiple files
touch Change file timestamps
tac Concatenate and write files in reverse
tail –n -f Output the last part of files(-n for no of lines, -f for changing the output if the file content is changed)
tty Print filename of terminal on stdin
uniq Uniquify files
uuencode Encode a binary file
uudecode Decode a file created by uuencode
which Locate a program file in the user’s path
locate Find files
printf Format and print data

4. Disk Related

df Display free disk space
fdformat Low-level format a floppy disk
fdisk Partition table manipulator for Linux
du Estimate file space usage
format Format disks or tapes
quota Display disk usage and limits
quotactl Set disk quotas
ram ram disk device
sync Synchronize data on disk with memory
quotacheck Scan a file system for disk usage

5. Hardware Information

dmesg Display messages in kernel ring buffer
lspci –tv Display PCI devices
lsusb –tv Display USB devices
dmidecode Display DMI/SMBIOS (hardware info) from the BIOS
hdparm -i /dev/sda Show info about disk sda
hdparm -tT /dev/sda Perform a read speed test on disk sda
badblocks -s /dev/sda Test for unreadable blocks on disk sda

6. Networking

ifconfig -a Display all network interfaces and ip address
ifconfig eth0 Display eth0 address and details
ethtool eth0 Query or control network driver and hardware settings
ping host Send ICMP echo request to host
whois domain Display whois information for domain
dig domain Display DNS information for domain
dig -x IP_ADDRESS Reverse lookup of IP_ADDRESS
host domain Display DNS ip address for domain
hostname -i Display the network address of the host name.
hostname -I Display all local ip addresses
wget http://domain.com/file Download http://domain.com/file

7. System Info Related

eject Eject CD-ROM
mount Mount a file system
umount Unmount a device
uname Print system information
arch Print machine architecture
shutdown Shutdown or restart linux
sleep Delay for a specified time
uptime Show how long the system has been running + load
last Show system reboot history

8. Schedule a command

cron Daemon to execute scheduled commands
crontab Schedule a command to run at a later time
nice Set the priority of a command or job
nohup Run a command immune to hangups
whereis Report all known instances of a command

9. Environment Variable related

env Display, set, or remove environment variables
printenv Print environment variables

10. Process Related

ps Display your currently running processes
ps -ef Display all the currently running processes on the system.
ps -ef | grep processname Display process information for processname
top Display and manage the top processes
htop Interactive process viewer (top alternative)
kill pid Kill process with process ID of pid
killall processname Kill all processes named processname
program & Start program in the background
bg Display stopped or background jobs
fg Brings the most recent background job to foreground
fg n Brings job n to the foreground

11. Performance Monitoring

top/ htop List processes running on the system
mpstat 1 Display processor related statistics
vmstat 1 Display virtual memory statistics
iostat 1 Display I/O statistics
tcpdump -i eth0 Capture and display all packets on interface eth0
tcpdump -i eth0 ‘port 80’ Monitor all traffic on port 80 ( HTTP )
lsof List all open files on the system
lsof -u user List files opened by user
free Display memory usage
watch df –h Execute “df -h”, showing periodic updates

12. Aliases

alias aliasName=”comand1″
aliasName to execute the comand1
alias aliasName shows the desc of the alias

13. Command Line Keyboard Shortcuts

ctrl + a to go to the start of the line
ctrl + e to go to the end of the line
ctrl + k to clear the content after the cursor to the end of the line
ctrl + u to delete everything before the cursor to the begining of the line
ctrl + w to delete one word before the cursor
ctrl + l to clear the screen except the current cmd prompt working
ctrl + t to swith one word to the left
ctrl + f to move forward one character
ctrl + b to move backward one character
ctrl + h to remove one charcter to the left of the cursor
ctrl + d to remove one charcter to the right of the cursor
ctrl + p to execute last cmd
clear clear the terminal screen
echo Display message on screen
less Display output one screen at a time
more Display output one screen at a time
screen Terminal window manager

14. Setting & Unsetting Environment Variables

export MYNAME=”TEST” to set the MYNAME value
echo $MYNAME displays MYNAME value
unset MYNAME to remove MYNAME from .bashrc file
write export or alias in .bashrc file for retaining the value of alias or alias when we restart the terminal

15. Command Line History

history to list out commands used before
history –c to clear the history records present in bash_history / all the cmnds typed in the terminals are listed in bash_history

16. Related to User/ Account

adduser Add a new user
passwd Modify a user password
su Substitute user identity
chown Change the user and group ownership of files
groups Print group names a user is in
id Print user and group id’s
useradd Create new user account
usermod Modify user account
users List users currently logged in
who Print all usernames currently logged in
whoami Print the current user id and name (`id -un’)
last Display the last users who have logged onto the system
w Show who is logged in and what they are doing
groupadd Create a group
userdel Delete a account

17. ARCHIVES (TAR FILES)

tar cf archive.tar directory Create tar named archive.tar containing directory.
tar xf archive.tar Extract the contents from archive.tar.
tar czf archive.tar.gz directory Create a gzip compressed tar file name archive.tar.gz.
tar xzf archive.tar.gz Extract a gzip compressed tar file.
tar cjf archive.tar.bz2 directory Create a tar file with bzip2 compression
tar xjf archive.tar.bz2 Extract a bzip2 compressed tar file.

18. INSTALLING PACKAGES

yum search keyword Search for a package by keyword.
yum install package Install package.
yum info package Display description and summary information about package.
rpm -i package.rpm Install package from local file named package.rpm
yum remove package Remove/uninstall package.

19. SSH LOGINS
ssh host Connect to host as your local username.
ssh [email protected] Connect to host as user
ssh -p port [email protected] Connect to host using port

20. FILE TRANSFERS
scp file.txt server:/tmp Secure copy file.txt to the /tmp folder on server
scp server:/var/www/*.html /tmp Copy *.html files from server to the local /tmp folder.
scp -r server:/var/www /tmp Copy all files and directories recursively from server to the current system’s /tmp folder.
rsync -a /home /backups/ Synchronize /home to /backups/home
rsync -avz /home server:/backups/ Synchronize files/directories between the local and remote system with compression enabled
21. Misc Commands
bc An arbitrary precision calculator language
cal Display a calendar
dc Desk Calculator
date Display or change the date & time
seq Print numeric sequences
man Help manual
units Convert units from one scale to another
wc Print byte, word, and line counts
watch Execute/display a program periodically
time Measure Program Resource Use
tr Translate, squeeze, and/or delete characters
tsort Topological sort
fmt Reformat paragraph text
expand Convert tabs to spaces
unexpand Convert spaces to tabs
factor Print prime factors
cksum Print CRC checksum and byte counts
ed A line-oriented text editor (edlin)
expr Evaluate expressions
false Do nothing, unsuccessfully
fold Wrap text to fit a specified width
info Help info
join Join lines on a common field
logname Print current login name
lpc Line printer control program
lpr Off line print
lprm Remove jobs from the print queue
mkfifo Make FIFOs (named pipes)
printcap Printer capability database
sed Stream Editor
select Accept keyboard input
test Evaluate a conditional expression
traceroute Trace Route to Host
true Do nothing, successfully
unshar Unpack shell archive scripts
xargs Execute utility, passing constructed argument list(s)
yes Print a string until interrupted

Pin It on Pinterest

Share This