Linux commands cheat sheet

System Commands

Command
Description
Examples
shutdown
bring your system down
shutdown -h now --> Halt or poweroff after shutdown
shutdown -r now --> Reboot after shutdown
halt
stop your system.
halt
reboot
reboot your system.
reboot
uptime
Tell how long the system has been running.
uptime
runlevel
find the previous and current system runlevel.
runlevel
printenv
print all or part of environment
printenv
env
run a program in a modified environment
env
hostname
show or set the system's your host name
hostname --> show the system's host name
hostname newhostname -->- set the system's
uname
print system information
uname -a --> print all information
locale
Displays information about the current locale, or all locales
locale
locale -a --> ll-locales



Process Management

Command
Description
Example
ps
Print out the current processes.
ps aux |grep nginx
ps aux | grep XXX | awk '{print $2}' | xargs kill -9
ps auxwf |grep XXX
pgrep
look up processes based on name and other attributes
pgrep -f 'bash'
pstree
The display a tree of processes
pstree -a
pidof
find the process ID of a running program
pidof nginx
kill
send a signal to a process
kill -9 PID
pkill
signal processes based on name and other attributes
pkill -f 'bash'
pkill -u huupv2
pkill java
pkill -f jar
killall
kill processes by name
killall vi
killproc


lsof
list open files
lsof -i :80,443
Ctrl + C
Stop running process

Ctrl + Z
Suspend running process
Move Running Process to Background
1. ctrl + z
2. jobs
3. bg
4. disown %JOBID
jobs
The first form lists the active jobs.
jobs -l <- List job
fg
Resume jobspec in the foreground

bg
Resume each suspended job jobspec in the background

nohup
run a command immune to hangups, with output to a non-tty
nohup command.sh &
nice
run a program with modified scheduling priority
nice -n 19 test.sh
nice -n 19 ionice -c 3 CMD
nice -n 19 ionice -c 2 -n 7 COMMAND
renice
alter priority of running processes
renice 19 -p PID
ionice
sets or gets process io scheduling class and priority
ionice -p PID
ionice -c 3 -p PID
nice -n 19 ionice -c 2 -n 7 COMMAND


Character

Command
Description
Example
lv
a Powerful Multilingual File Viewer / Grep

nkf
Network Kanji Filter

iconv
Convert encoding of given files from one encoding to another


Comments

Popular posts from this blog

zimbra some services are not running [Solve problem]

Bash script list all IP addresses connected to Server

How to install php7 on centos 6