Basics Flashcards
View Specific Disk Partition
fdisk -l /dev/sda
View all Disk Partitions
fdisk -l
Find Out Top File Sizes
find -type f -exec du -Sh {} + | sort -rh | head -n 5
Disk space usage: Exclude Certain File System Type
df -x ext3
Disk space usage: Display Certain File System Type
df -t xfs
Display File System Inodes
df -i
File space usage: grand total for each argument
du -ch
File space usage: summary of a grand total disk usage size
du -sh
File space usage: displays the number of disk blocks
du
list running services
systemctl list-units --type=service --state=running
rpm package manager
query all packages
rpm -qa
kernel parameters
sysctl -a
display the largest folders/files including the sub-directories
du -Sh | sort -rh | head -5
how to handle this:
> $ sudo echo ‘127.0.0.1 bob’»_space; /etc/hosts
zsh: permission denied: /etc/hosts
> $ echo ‘127.0.0.1 bob’ | sudo tee -a /etc/hosts
[sudo] password for gludwig:
127.0.0.1 bob
all Available fdisk Commands
fdisk /dev/sda
rsync: Count files recursively through directories
rsync –stats –dry-run -ax /etc /test
rsync –stats –dry-run -ax .
all File System Disk Space Usage
df -a
compile options
cat /boot/config-$(uname -r)
loaded kernel modules
lsmod
is a trivial program which nicely formats the contents of the /proc/modules, showing what kernel modules are currently loaded.
generate password having length 64
mkpasswd -l 64
Find Top 15 Processes by Memory Usage
top -b -o +%MEM | head -n 22
cat | cut
cat report.csv |cut -f 5-11,13- -d’,’ > cleanreport.csv
cat | sudo tee
cat
> new_file
> new_file
text text
^C
Disk space usage: display type
df -Thl
contents of an initramfs image
sudo lsinitrd
kernel ring messages
dmesg -T
which packages provides a tool
dnf whatprovides mkpasswd
search largest folder
sudo du -hax –exclude=”./usr/lib” / | sort -r -h | head -30 2> /dev/null
copy with attributes remaining
cp -a
full shell login
su -l
count of searched words in files
grep -r SEARCHED_WORD | wc -w
list file names in which the searched word is found
grep -l SEARCHED_WORD
list active services
systemctl list-units –type=service –state=active
list enabled services
systemctl list-unit-files | grep enabled
rpm package manager
list all files in a package
rpm -ql package_name
rpm package manager
find package which provides a files
rpm -qf $(which kill)
similar to:
dnf whatprovides kill
print a sequence of numbers
with equal width from 0 to 10 step 2
seq -w 0 2 10
print a sequence of numbers
comma separated from 1 to 100 step 1
seq -s, 1 1 100
write consecutive numbers from 0 to 9 in two columns
seq -w 0 9 | paste - -
grep: invert search result
grep -v SEARCH_TERM
grep empty lines
grep ‘^$’
grep file content without empty lines
cat sample.txt | grep -v ‘^$’