Linux Commands Flashcards
Check OS version
cat /etc/redhat-release
rpm -q centos-release
vi tips - moving the cursor
V - selects entire lines
v - selects range of text
:set number | v - copy
:set nonumber | p -paste
0 - move cursor to start of line | x - cut+paste
:0 - first line
$ - move cursor to end of line
:$ - last line
w - next word
b - preceding word
toggle between the last two directories
cd -
Use dirs, pushd and popd
to manipulate directory stack
dirs
pushd
popd
vi tips II
% Find matching () { or } d Delete
^l Redraw screen dd Delete line
^r Refresh screen c Change
z Current line at top y Yank lines to buffer
z- Current line at bottom C Change rest of line
^e Scroll down one line D Delete rest of line
^y Scroll up one line s Substitute character
`` Previous context S Substitute lines
H Home window line J Join lines
L Last window line x Delete after
M Middle window line X Delete before
+ Next line Y Yank current line
hjkl Cursor movement: p Put back lines
left/down/up/right P Put before
0 Beginning of line > Shift line right
f Find forward u Undo last change
F Find backward U Restore current line
ZZ Exit, saving changes t Up to forward Q Enter ex mode T Back up to End of insert | Go to columnExecute ex command w,W Forward one word
:! Shell command b,B Back one word
^g Show filename/size e,E End of word
^f Forward one screen ^h Erase last character
^b Back one screen ^w Erase last word
^d Forward half screen ^? Interrupt
^u Backward half screen ~ Toggle character case
G Go to line a Append after
/ Search forward for i,I Insert before
? Search backward for A Append at end of line
n Repeat last search o Open line below
N Reverse last search O Open line above
]]fGOTO
Next section/function r Replace character
[[ Previous section/function R Replace characters
vi Options:
autoindent Automatic line indentation
autowrite Write before quit
ignorecase Ignore case in searches
number Display line numbers
showmatch Show matches to ) and } as typed
terse Quiet mode
wrapscan Wraparound in searches
wrapmargin Automatic line splitting
q Quit set Enable option
q! Quit, discard changes set no Disable option
r Read in file set all Show all options
sh Invoke shell
vi Vi mode
wq Write and quit
w Write file
w! Overwrite file
/Emilee Tellez
verify syslog is installed
rpm -qa | grep syslog
verify rsyslog service is set to start
chkconfig rsyslog –list
chkconfig rsyslog –level 2345 on
ls - no details
ls -a
ls -A (no implicit “.” or “..”)
ls -aF (classify ex. “/”)
ls group directories first
ls –group-directories-first
check running level
runlevel
change running level
init 3 (0 - 6)
GRUB abbreviation
Grand Unified Bootloader
grubby –update-kernel=ALL –args=”…”
grubby –update-kernel=ALL –args=”video=hyperv_fb:1024x768”
check listening ports with netstat
netstat -ant (all TCP ports numeric list)
check listening ports with list open files
lsof -i :8080 (ex port 8080vi /etc/rsysl)
restart network service
service network restart
Hyper-v install cdrom module
insmod /lib/modules/$(uname -r)/kernel/drivers/ata/ata_piix.ko
lsmod | grep piix
rmmod …
The file contains gateway?!? and host info
/etc/sysconfig/network
ifconfig add/delete secondary (subinterface) interface
ifconfig eth0:0 10.10.20.218 netmask 255.255.255.0 up
ifconfig eth0:0 del 10.10.20.218
ip address add
ip address add 192.168.99.37/24 dev eth0
you can add more than one IP (the additional become secondary)
add a permanent secondary IP
cp the existing ifg-ethx them edit it, removing the gateway and changing the name: DEVICE=eth0:1 BOOTPROTO=static ONBOOT=yes IPADDR=10.1.1.2 NETMASK=255.255.255.0
List all processes
Display tree
ps aux | less
-A all processes
a all proc on term (+ other users)
x —||— (w/o controlling ttys)
pstree
pgrep firefox get process ID by name
kill
kill PID (simply kill a PID) kill -KILL (bypass the program & send to OS kernel)
kill -l list signals
kill -0 -HUP (restart daemon w Hang-Up signal)
kill -9 -KILL
grep (case insensitive)
grep -i