during studying for LPIC-1 I made some notes; unfortunately in German, so it is quite stupid to write this description in English
dig cheatsheet neverendingsecurity.wordpress.com
sar from the package sysstat shows the processor activity, this gives five measurements every three seconds:
sar 3 5
sar also could be used to measure network interfaces and I/O transfer rates, first command measure one time for five seconds:
sar -n DEV 5 1
this command measures the I/O rates every 10 seconds three times:
sar -b 10 3
to collect data over a longer period, we have to set ENABLED="true" in /etc/default/sysstat and start the service.
After ten minutes we can see the collected data with:
sar -A
iostatfrom sysstat is similar to sar when running without attributes
iostat -c
iostat -d
iostat -h
iostat -x
iotop show I/O like command top. To show the current I/O processes do this:
iotop -o
other commands
vmstat
netstat
ss
iptraf
pscommand:
instead of using ps aux | grep tomcat we could search for java processes with:
ps u -C java
ps -fC java
ps -fC java,apache2
other commands
pstree
top
more modern than top with color an scrolling:
htop
show load an uptime with:
uptime
w
show what file is open at an external drive
lsof /media/mydrive
identify current kernel version:
uname -r
compile commands
make config
make oldconfig
make menuconfig
make dep
make clean
make bzImage
make modules
make modules_install
show state of the modules of the running kernel.
lsmod
basically shows the content of /proc/modules
inspect the modules of a kernel
modinfo
options of modinfo:
other mod commands
At runtime the kernel stores its information in the /proc file system under /proc/sys/kernel/
cd /proc/sys/kernel/
cat osrelease
cat ostype
cat hostname
cat domainname
cat modprobe
show which files are open in a mounted drive
lsof /media/disk/
udev manges /dev. Configuration at /dev/udev/.
To monitor udev:
udevadm monitor
lot of information about a process:
cat /proc/9842/environ | tr "\000" "\n"
the tr is needed here, to have a line break after every parameter
show differnces in systemd config
systemd-delta
create backup of the MBR
dd if=/dev/sda of=mbr.backup ibs=512 count=1
update grub after installing new kernerl
update-grub2
check file system
fsck -t ext4 -V /dev/sdb1
parameters of the mount command
remount
mount -v -o remount,rw /path
NFS mount
mount -t nfs pcname:/path /mnt
SMB mount
mount -t smbfs //pcname/share /mnt
Content of /etc/fstab:
1 file system | 2 mount point | 3 type | 4 options | 5 dump | 6 pass |
---|---|---|---|---|---|
UUID=9ae73f06-5ee6-45f5-8f55-c4837bc7ca2a | / | ext4 | errors=remount-ro | 0 | 1 |
UUID=d583c4be-8d35-4bb5-bc81-cda80e1606b4 | none | swap | sw | 0 | 0 |
UUID=58236382-9d8f-40a5-ba65-0bc431df69aa | /home | ext4 | acl,user_xattr | 1 | 2 |
column 5 defines, if the file system is saved by dump
column 6 defines, if and when a file system is checked by fsck:
find UUID of your partitions
blkid
no fsck when start next time
shutdown -hf now
force fsck when start next time
shutdown -hF now
LVM
ip command cheatsheet acces.redhat.com (pdf)
ifconfig eth1 192.168.1.111 netmask 255.255.255.0
route add default gw 192.168.1.1
route add -net 192.168.191.0/24 gw 192.168.190.1
route -A inet6
Delete arp entry:
arp -d 192.168.1.1
ip command:
ip route show
# same as route -n command
ip neighbour show
# same as arp command
ip addr show eth0
# same as ifconfig command
ip tunnel show
# capsulated ipv6 packages in ipv4 packages
ip monitor
# live monitoring of arp table
wifi commands
iwconfig wlan0
iwconfig wlan0 txpower 30mW
iwlist wlan0 frequency
iwlist --help
Usage: iwlist [interface] scanning [essid NNN] [last]
[interface] frequency
[interface] channel
[interface] bitrate
[interface] rate
...
iw dev wlan0 link
# same as iwconfig wlan0
some network commands:
ifconfig eth0:1 172.16.111.111
route add -net 172.16.111.0/16 gw 172.16.111.1
route add -A inet6 2001:6f8:1cfe:1::/64 gw 2001:6f8:1cfe:0::4
route -A inet6
ss -tulpn
lsof -i -n -P
ip address add 172.16.1.123/24 dev eth0
ip address add 2a01:198:5dd::47/64 dev eth0
ip route add 172.16.1.0/24 via 192.168.1.1
ip address add 2001:6f8:1cfe:4f44::/64 via 2001:6f8:1cfe::4
nmap server.tld.com
nmap server.tld.com -P0
nmap -P0 192.168.0.0/24
nmap -P0 -p 80,443 192.168.0.0/24
mtr 192.168.0.1
apt-get install linux-headers-$(uname -r)
tar xvzf mytarball.tar.gz
tar xvzf mytarball.tar.gz --directory=/opt/
tar cvzf /path/mytarball.tar.gz /myfolder/
-x – extract
-c – create
-z – gzip/gunzip
-j – bzip2/bunzip2
-J – xz/unxz
-v – verbose
-t – table; list all files of the archive, without extracting
-f – file: has to be the last one before the file
tar cvf /dev/st0 /home – tape archive of /home
tar xvf /dev/st0 /home/daniel/important.doc – tape archive restore important.doc
gzip -c bachelorthesis.doc > bachelorthesis.doc.gz
gzip -l bachelorthesis.doc.gz
gunzip bachelorthesis.doc.gz
gzip -d bachelorthesis.doc.gz
zcat bachelorthesis.doc.gz
bzip2 file
bzip2 -c file > file.bz2
bunzip2 file.bz2
bzip2 -d file.bz2
bzcat file.bz2
xz file
xz -c file > file.bz2
unxz file.bz2
xz -d file.bz2
xzcat file.bz2
/dev/st0
/dev/nst0
/dev/ft0
/dev/nft0
dd if=/dev/sda of=/dev/sdb
dd if=/dev/sda of=mbr.backup ibs=512 count=1
systemctl poweroff