Show Menu
Cheatography

Linux for DBA - 1 Cheat Sheet by

Linux commands useful for a DBA

Basic

man <co­mmand name>
help about the command
<co­mmand A> | <co­mmand B>
send output of A in input to B
<no­mec­oma­ndo> &
execute in background
jobs
show all the background
nohub <co­man­do> <fi­len­ame>
launch and protect the process
w
show the session
fg %1
return to foreground
cat <fi­len­ame>
print the content of file in the terminal

File navigation and Basic Operations

pwd
print working directory
cd <pa­th>
change driectory to <pa­th> cd ~
ls -lrt
directory file list with details
touch
create a file
mv <pa­th1­+fi­len­ame> <pa­th2>
move the file in path1 to path2, it can used to rename file
cp <pa­th1­+fi­len­ame> <pa­th2>
copy, same as above
file <fi­len­ame>
show the file-type
ls -lrt <fi­len­ame>
details about the file
stat <fi­len­ame>
tail -f
show last rows of the file and keep update (live mnonit­oring)
vi <fi­lna­me>
open the file with vi editor

File Permission

chmod <nm­z> <fi­len­ame>
update the file permission
chown <new owner userna­me> <fi­len­ame>
update file owner
umask
show default mask

Main Direct­ories

/etc
config­uration files
/var/log
log files
/tmp
temp. files
/home/­<us­er>
home directory
which <co­mmand name>
find an executable
 

PC details and monitoring

cat /proc/­meminfo
ram info
cat /proc/­cpuinfo
cpu info
lshw
other info about the PC
memstat 1
real time of values
vmstat 1
Virtual memory stat.
iostat 1
IO metrics, realtime
iotop
similar to iostat
top or htop (if installed)
show resources
ipcs -m
processes shared memory

Processes

ps -ef
show processes
ps aux
altern­ative version, useful for mem . info
top or htop (if installed)
show resources
ipcs -m
processes shared memory
kill <PI­D>
kill a process
lsof
tands for LiSt Open Files and shows open files and which process uses them
lsof -Pp <pi­d>
file list used by the process <pi­d>
lsof -Pp <pi­d> | grep log
search for the log related to <pi­d>

Enviro­nments

env
display enviro­nments variables
<va­riable name> = <var. conten­t>
set a shell variable
export <va­riable name> = <var. conten­t>
create subshell with env variables
source <file name>
akes available the variable in the file for the current shell
echo ${<­var­iable name>}
display the variables content
export <va­riable name>
send the variable to the subshells
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Vim NERDTree Cheat Sheet