End-to-End Linux commands sheet for Dev-Ops
End-to-End Linux commands sheet for Dev-Ops
| AKHIL THYADI
Linux Commands
📁 1. File & Directory Management
This section covers the essential commands used to interact with the Linux file system. It explains
how to navigate directories, create and manage files and folders, list contents, understand paths
(absolute and relative), and manage permissions. Mastering these commands is fundamental to using
Linux effectively in any environment.
📌 Topics Explained:
user@717e40ca0442:~$ pwd
/home/user
2. List of files = ls
user@717e40ca0442:~$ ls
answer.txt task_1
user@717e40ca0442:~$ ls -a
. .. .bash_logout .bashrc .profile answer.txt task_1
user@717e40ca0442:~$ cd ..
user@717e40ca0442:/home$
user@717e40ca0442:/home$ cd
user@717e40ca0442:~$
Linux Commands
6. Change directory to specific directory = cd <directory>
user@717e40ca0442:~$ cd task_1
user@717e40ca0442:~/task_1$
user@717e40ca0442:~/task_1$ cd-
user@717e40ca0442:~$
user@717e40ca0442:~$ ls
answer.txt task_1 test test_1
user@717e40ca0442:~$ cd test_1
user@717e40ca0442:~/test_1$ ls
test_2
user@717e40ca0442:~/test_1$ cd test_2
user@717e40ca0442:~/test_1/test_2$ ls
test_3
user@717e40ca0442:~/test_1/test_2$ cd test_3
user@717e40ca0442:~/test_1/test_2/test_3$
user@717e40ca0442:~/test_1/test_2/test_3$ cd
user@717e40ca0442:~$
user@717e40ca0442:~$ cd test_1
user@717e40ca0442:~/test_1$ cd test_2
user@717e40ca0442:~/test_1/test_2$ cd test_3
user@717e40ca0442:~/test_1/test_2/test_3$ cd /home/user
user@717e40ca0442:~$
user@717e40ca0442:~$ cd /
user@717e40ca0442:/$ ls
bin boot dev ecs-execute-command-59bc2f9b-d05b-44c1-a0e9-801104dbaf2a etc home lib lib32
lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
Linux Commands
11. Dictionary or manual of all commands = man <cmnd>
user@717e40ca0442:/$ man ls
user@717e40ca0442:~$ pwd; ls
/home/user
answer.txt task_1 test test_1
DANGER
user@717e40ca0442:~$ rm -rf / # It will forcefully delete the directory and files starting from the
user.
user@717e40ca0442:~$ cd /bin
user@d5cc04afe2b3:~$ pwd; ls
/home/user
answer.txt task_1
user@d5cc04afe2b3:/bin$
user@d5cc04afe2b3:/bin$ cd
user@d5cc04afe2b3:~$ cp -r /home /tmp # Copying the home directory recursively and pasting it in
tmp directory
user@d5cc04afe2b3:~$ cd /tmp
user@d5cc04afe2b3:/tmp$ ls
file.zip home setup
20. To copy directory files to another directory or folder without copying the directory
user@d5cc04afe2b3:/tmp$ cp -r /home/* /tmp # * will copy the all files recursively in a directory
and leaves the directory
user@d5cc04afe2b3:/tmp$ ls
file.zip home setup user
user@d5cc04afe2b3:/tmp$ cd user; ls
answer.txt file task_1
user@d5cc04afe2b3:/tmp/home/user$ vi file_name
27. To view or read 'N' no of bottom lines in a file = tail -num <file_name>
28. To view or read 'N' no of top lines in a file = head -num <file_name>
user@d5cc04afe2b3:/tmp/home/user$ free
total used free shared buff/cache available
Mem: 3876468 332916 927948 1076 2615604 3251872
Swap: 0 0 0
30. To view the available memory space in human readable format = free -h
user@d5cc04afe2b3:/tmp/home/user$ free -h
total used free shared buff/cache available
Mem: 3.7Gi 325Mi 906Mi 1.0Mi 2.5Gi 3.1Gi
Swap: 0B 0B 0B
Linux Commands
System Access Management
This section is focused on managing users, groups, and access control in a Linux system. It's vital for
ensuring system security and controlling access to files and directories. This is commonly used by
system admins to manage multi-user environments.
📌 Topics Explained:
user@ddde4a3e1ec3:~$ whoami
user
# sudo acts like a root user and it has all the permissions like the root user.
user@ddde4a3e1ec3:~$sudo userdel
[sudo] password for user:
Linux Commands
7. Delete group = sudo groupdel
user@ddde4a3e1ec3:~$sudo groupdel
[sudo] password for user:
scaler:x:1002:1002::/home/scaler:/bin/sh
9. To search the user details in the list of users = cat /etc/passwd | grep <username>
user@ddde4a3e1ec3:~$ su scaler
Password:
$ whoami
scaler
$ exit
user@ddde4a3e1ec3:~$ history
1 whoami
2 sudo useradd scaler
3 cat /etc/passwd
4 cat /etc/passwd | grep scaler
5 cat /etc/passwd | grep -i scaler
6 sudo passwd scaler
7 su scaler
8 cat /etc/passwd | grep -i scaler
9 history
Linux Commands
13. Shortcut to write any command that we have used earlier in the terminal = Ctrl + R
(reverse-i-search)`ge': getfacl answer.txt # In Terminal press Ctrl + R, it gives this line and we need to
start typing the command and the terminal will suggest the command that we are looking for, which is
called reverse search.
user@63f082294dbc:~$ getfacl answer.txt
user@ddde4a3e1ec3:~$ ls -ltra
total 20
-rw-r--r-- 1 user user 807 Mar 31 2024 .profile
-rw-r--r-- 1 user user 3771 Mar 31 2024 .bashrc
-rw-r--r-- 1 user user 220 Mar 31 2024 .bash_logout
drwxr-xr-x 1 root root 4096 Sep 6 09:58 ..
drwxr-x--- 2 user user 4096 Sep 6 09:58 .
15. To change the ownership of a file = sudo chown user_name : group_name <filename>
user@ddde4a3e1ec3:~$ ls -ltra
total 28
-rw-r--r-- 1 user user 807 Mar 31 2024 .profile
-rw-r--r-- 1 user user 3771 Mar 31 2024 .bashrc
-rw-r--r-- 1 user user 220 Mar 31 2024 .bash_logout
drwxr-xr-x 1 root root 4096 Sep 6 09:58 ..
drwxrwxr-x 2 scaler scaler 4096 Nov 14 09:04 ubuntu # The user and group name has changed to
scaler from user
drwxr-x--- 1 user user 4096 Nov 14 09:04 .
16. To change the permissions for files using numeric expression's = sudo chmod 777 <filename>
17. To change the permissions for files using alphabetic expression's = sudo chmod [ugoa][+-=][rwx]
<filename>
user@ddde4a3e1ec3:~$ cd /
user@ddde4a3e1ec3:/$ ls -ltra
total 84
drwxr-xr-x 2 root root 4096 Apr 8 2024 lib.usr-is-merged
drwxr-xr-x 2 root root 4096 Apr 8 2024 sbin.usr-is-merged
drwxr-xr-x 2 root root 4096 Apr 8 2024 bin.usr-is-merged
lrwxrwxrwx 1 root root 8 Apr 22 2024 sbin -> usr/sbin # Here it's a shortcut created to sbin ->
it will re-direct to usr/sbin
20. To get permissions details of all users and groups for any particular file = getfacl <filename>
user@63f082294dbc:~$ getfacl answer.txt # This will give the list of users and groups that have
permissions for this answer.txt file.
Linux Commands
21. To check the user permissions of any file or directory = vi /etc/sudoers
" ============================================================================
" Netrw Directory Listing (netrw v165)
" /etc/sudoers.d
" Sorted by name
" Sort sequence:
[\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:special
" ==============================================================================
../
./
README
user
~
~
~
~
~
"/etc/sudoers" [Permission Denied] # But the permission is denied to view
22. To get the permission as a super user or root user here we have to use sudo
user@7b05bce9df89:~$ sudo vi /etc/sudoers # This will give access to view the permission details in
that file
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
#includedir /etc/sudoers.d
~
~
23. To specify the groups and users with specific permission for any particular file we have to Insert
#includedir /etc/sudoers.d
scaler ALL=(ALL) ALL NOPASSWD: ALL # For giving sudo access to a user
%groupname scaler ALL=(ALL) ALL NOPASSWD: ALL # For giving sudo access to a group
~
Linux Commands
Interview Question:
Imagine you are a DevOps Engineer and you are asked to setup development environment for new
application project and the project team consists of three things they are Developers, Testers and
Project Managers. You have to ensure that developer has access to the source code, and they can
deploy on the deployment servers, second Testers should have access to the testing environment but
they cannot make any changes to source code and the Project Manager should access to can view the
access reports and the progress but cannot modify anything in the code. You have to Create Groups
according to use case and Create Users and assign Users to Groups and Create Directories like Project,
Testing and Reports. And you have assign correct Ownership and Permissions that will be there to all
these Projects and Directories.
user@1ef819edc6f9:~$ pwd
/home/user
user@1ef819edc6f9:~$ ls
Dev PM Test
user@1ef819edc6f9:~$ ls -ltra
total 36
-rw-r--r-- 1 user user 807 Mar 31 2024 .profile
-rw-r--r-- 1 user user 3771 Mar 31 2024 .bashrc
-rw-r--r-- 1 user user 220 Mar 31 2024 .bash_logout
Linux Commands
drwxr-xr-x 1 root root 4096 Sep 6 09:58 ..
drwxr-xr-x 2 root root 4096 Nov 15 09:52 Dev
drwxr-xr-x 2 root root 4096 Nov 15 09:52 Test
drwxr-xr-x 2 root root 4096 Nov 15 09:52 PM
drwxr-x--- 1 user user 4096 Nov 15 09:52 .
# Here we see the DEVELOPER, TESTER, PROGRAM_MANAGER Groups are the owners of their
Directories
📌 Topics Explained:
• Soft Link (ln -s) – A shortcut that points to the original file. Breaks if the original file is deleted.
• Hard Link (ln) – A direct reference to the file data on disk. Persists even if the original file is
deleted.
• Use Cases – Managing project dependencies, simplifying navigation, and maintaining backup
copies.
Soft Link
user@ebfc42bdd95d:~$ pwd; ls
/home/user
user@ebfc42bdd95d:~$ mkdir test # Creates a test directory
user@ebfc42bdd95d:~$ vi abc.txt # Creates a file
user@ebfc42bdd95d:~$ ls
abc.txt test
user@ebfc42bdd95d:~$ cd test/
user@ebfc42bdd95d:~/test$ ls # Nothing is present inside of test directory
user@ebfc42bdd95d:~/test$ ln -s /home/user/abc.txt /home/user/test/xyz.txt # Creating a link file
named xyz.txt of abc.txt file in test directory
user@ebfc42bdd95d:~/test$ ls -ltra
total 8
drwxr-x--- 1 user user 4096 Nov 15 10:19 ..
lrwxrwxrwx 1 user user 18 Nov 15 10:19 xyz.txt -> /home/user/abc.txt # Here it clearly shows that
xyz.txt is a link of original file abc.txt
drwxrwxr-x 2 user user 4096 Nov 15 10:19 .
user@ebfc42bdd95d:~$ ls -ltra
total 36
-rw-r--r-- 1 user user 807 Mar 31 2024 .profile
-rw-r--r-- 1 user user 3771 Mar 31 2024 .bashrc
-rw-r--r-- 1 user user 220 Mar 31 2024 .bash_logout
drwxr-xr-x 1 root root 4096 Sep 6 09:58 ..
lrwxrwxrwx 1 user user 18 Nov 15 10:19 xyz.txt -> /home/user/abc.txt
-rw-rw-r-- 1 user user 9 Nov 15 10:21 hard_link_original.txt # Hard link original file is present in
/home/user
-rw------- 1 user user 1014 Nov 15 10:21 .viminfo
drwxr-x--- 1 user user 4096 Nov 15 10:21 .
drwxrwxr-x 2 user user 4096 Nov 15 10:22 test
user@ebfc42bdd95d:~$ ls
hard_link_original.txt test xyz.txt
user@ebfc42bdd95d:~$ cd test/
user@ebfc42bdd95d:~/test$ ls -ltra
total 8
lrwxrwxrwx 1 user user 18 Nov 15 10:19 xyz.txt -> /home/user/abc.txt
drwxr-x--- 1 user user 4096 Nov 15 10:21 ..
lrwxrwxrwx 1 user user 33 Nov 15 10:22 hard_link_copy.txt -> /home/user/hard_link_original.txt
# Hard link copy file is present in /home/user/test
lrwxrwxrwx 1 user user 33 Nov 15 10:22 hard_link_copy.txt
drwxrwxr-x 2 user user 4096 Nov 15 10:22 .
user@ebfc42bdd95d:~/test$ cd ..
user@ebfc42bdd95d:~$ rm hard_link_original.txt # removing the hard_link_original.txt file
user@ebfc42bdd95d:~$ cd test/
user@ebfc42bdd95d:~/test$ ls -ltra
total 8
lrwxrwxrwx 1 user user 18 Nov 15 10:19 xyz.txt -> /home/user/abc.txt
lrwxrwxrwx 1 user user 33 Nov 15 10:22 hard_link_copy.txt -> /home/user/hard_link_original.txt
# Hence after deleting the hard_link_original_file the replica or exact copy is present in test directory
without getting deleted
lrwxrwxrwx 1 user user 33 Nov 15 10:22 hard_link_copy.txt
drwxrwxr-x 2 user user 4096 Nov 15 10:22 .
drwxr-x--- 1 user user 4096 Nov 15 10:24 ..
Interview Questions:
1. I'm trying to create an empty directory, but I'm unable to create it what is the issue ?
A. Inodes
Inodes are the data structures that stores information about files and directories, for suppose in our
system if there is any program where it is creating faulty temporary files which are very minimum of
size just in bytes. At some point of time one of our file stopped writing the log files but there is enough
space but unable to write logs. Where this new file creating faulty temporary files where space is not
exhausted but Inodes got exhausted this leads to send an error while creating a new directory.
Command: df -I # this will give the entire details about Inodes
bashrc is a hidden file in system, whenever we run a new terminal it will start in the interactive mode
in the bashrc and in the bashrc whatever configurations are there the shell will taking those
configurations and runs it
📌 Topics Explained:
1. Process status = ps
user@bb0e91c81fda:~$ ps
PID TTY TIME CMD
145 pts/1 00:00:00 sh
146 pts/1 00:00:00 bash
496 pts/1 00:00:00 ps
user@bb0e91c81fda:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 1136 512 ? Ss 06:46 0:00 /sbin/docker-init -- /usr/bin/tini --
/usr/local/bin/j
root 62 0.0 0.0 2504 1408 ? S 06:46 0:00 /usr/bin/tini -- /usr/local/bin/judge/setup.sh
root 63 0.0 0.0 3984 3072 ? S 06:46 0:00 /bin/bash /usr/local/bin/judge/setup.sh
root 73 0.0 0.4 1757316 15788 ? Ssl 06:46 0:00 /ecs-execute-command-e264bcc5-2940-
4fd2-91c9-06543307a
root 99 0.0 0.0 4524 2816 ? S 06:46 0:00 su - user -c ttyd -W -p 7681 --ping-interval 45 -t
fon
user 101 0.0 0.0 2616 1536 ? Ss 06:46 0:00 -sh -c ttyd -W -p 7681 --ping-interval 45 -t
fontSize=
user 105 0.0 0.0 10116 1280 ? Rl 06:46 0:00 ttyd -W -p 7681 --ping-interval 45 -t fontSize
16 bash
root 129 0.0 0.6 1766992 26032 ? Sl 06:46 0:00 /ecs-execute-command-e264bcc5-2940-
4fd2-91c9-06543307a
root 140 0.0 0.0 2552 1408 ? S 06:46 0:00 tail -f /dev/null
user 141 0.0 0.0 4116 3328 pts/0 Ss+ 06:46 0:00 bash
Linux Commands
user 144 0.0 0.0 2644 1920 pts/0 R+ 06:46 0:00 script -a -q -f -o 500M
/mnt/.script_logs/script.log -
user 145 0.0 0.0 2616 1536 pts/1 Ss 06:46 0:00 sh -c bash
user 146 0.0 0.0 4248 3456 pts/1 S 06:46 0:00 bash
user 333 0.0 0.0 5900 2816 pts/1 R+ 06:51 0:00 ps aux
user@bb0e91c81fda:~$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 06:46 ? 00:00:00 /sbin/docker-init -- /usr/bin/tini --
/usr/local/bin/judge/setup.sh
root 62 1 0 06:46 ? 00:00:00 /usr/bin/tini -- /usr/local/bin/judge/setup.sh
root 63 62 0 06:46 ? 00:00:00 /bin/bash /usr/local/bin/judge/setup.sh
root 73 0 0 06:46 ? 00:00:00 /ecs-execute-command-e264bcc5-2940-4fd2-91c9-
06543307ae13/amazon-ssm-
root 99 63 0 06:46 ? 00:00:00 su - user -c ttyd -W -p 7681 --ping-interval 45 -t fontSize=16
bash
user 101 99 0 06:46 ? 00:00:00 -sh -c ttyd -W -p 7681 --ping-interval 45 -t fontSize=16 bash
user 105 101 0 06:46 ? 00:00:00 ttyd -W -p 7681 --ping-interval 45 -t fontSize 16 bash
root 129 73 0 06:46 ? 00:00:00 /ecs-execute-command-e264bcc5-2940-4fd2-91c9-
06543307ae13/ssm-agent-w
root 140 63 0 06:46 ? 00:00:00 tail -f /dev/null
user 141 105 0 06:46 pts/0 00:00:00 bash
user 144 141 0 06:46 pts/0 00:00:00 script -a -q -f -o 500M /mnt/.script_logs/script.log --
timing=/dev/nu
user 145 144 0 06:46 pts/1 00:00:00 sh -c bash
user 146 145 0 06:46 pts/1 00:00:00 bash
user 345 146 0 06:51 pts/1 00:00:00 ps -ef
user@f26bf64d9bce:~$ top
# Top command gives information about running process like process ID(PID), priority(PR),
Niceness(NI), Memory percentage(%MEM)
user@bb0e91c81fda:~$ pgrep sh
63
101
141
145
146
user@bb0e91c81fda:~$ pgrep ttyd
105
user@bb0e91c81fda:~$ pgrep docker-init
1
user@bb0e91c81fda:~$ bg %1
bash: bg: job 1 already in background
Linux Commands
9. To bring a job to the Foreground = fg %<PID>
user@bb0e91c81fda:~$ fg %1
sleep 100
user@f26bf64d9bce:~$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
user@f26bf64d9bce:~$ kill 20
user@f26bf64d9bce:~$ kill -9 20 # This will kill any PID forcefully
Pipe is used for the output of one program will be an input to another program
in terminal 1
user@f26bf64d9bce:~$ echo "rat" > pipe
in terminal 2
user@f26bf64d9bce:~$ less < pipe # the output of terminal 1 is reflected to terminal 2
rat
in terminal 1
user@f26bf64d9bce:~$ echo "rat_1" > pipe
in terminal 2
user@f26bf64d9bce:~$ tee output.log < pipe | tail -f # the output of terminal 1 is reflected to
terminal 2
rat_2
Linux Commands
13. To show active IPC(Inter Process Communication's) resources to show message queues, shared
memory segments, semaphore array
user@f26bf64d9bce:~$ ipcs
Interview Questions:
Q. How do you handle high CPU utilization, You receive an alert on your machine there is high CPU
utilization at the same time you receive message from one of the management people that some
tasks are blocked. How will you tackle the both tasks at a time.
I will be using top command from "top" command what are the processes running what are the top
processes that consuming high CPU, I will see whether these processes are expected or not, I will see
whether these processes are system generated or cron jobs running or batch processes are running.
Now then I will see whether it is critical or not, this job it might be a possibility that some of the cron
jobs run during peak times which are might not important, I will kill those job for that particular time
and restart them after the peak time to reduce the load on the CPU.
The other scenario receiving messages from management there is an high priority tasks that needs to
be take care, I will increase niceness of that tasks to -5 or -10 or -15 based on other processes
niceness.
Linux Commands
Memory & Storage Management
This section discusses how to monitor and optimize system memory and storage in Linux. Efficient
memory management ensures better performance and reliability, especially in production or resource-
constrained systems.
📌 Topics Explained:
user@934cc9d6b341:~$ free -h
total used free shared buff/cache available
Mem: 3.7Gi 743Mi 231Mi 3.4Mi 3.0Gi 3.0Gi
Swap: 0B 0B 0B
2. To provide summary of memory, CPU, and I/O usage we use virtual memory statatics
= vmstat 1 5
user@934cc9d6b341:~$ vmstat 1 5
procs -----------memory---------- ---swap-- -----io---- -system-- -------cpu-------
r b swpd free buff cache si so bi bo in cs us sy id wa st gu
2 0 0 230260 128428 3057824 0 0 24604 150644 210996 7 1 1 98 1 0 0
0 0 0 230260 128428 3057824 0 0 0 132 574 1039 0 0 100 0 0 0
0 0 0 230260 128428 3057824 0 0 0 0 516 967 1 0 99 0 0 0
0 0 0 230260 128428 3057824 0 0 0 0 468 891 0 0 100 0 0 0
0 0 0 230260 128428 3057824 0 0 0 148 537 952 0 0 99 0 0 0
user@934cc9d6b341:~$ top
top - 16:16:53 up 0 min, 1 user, load average: 0.04, 0.05, 0.06
Tasks: 18 total, 1 running, 17 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.3 sy, 0.0 ni, 99.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3785.6 total, 233.2 free, 743.1 used, 3111.0 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 3042.5 avail Mem
5. To get detailed memory usage per process, including shared memory = smem
user@934cc9d6b341:~$ smem
user@934cc9d6b341:~$ free -h
total used free shared buff/cache available
Mem: 3.7Gi 789Mi 326Mi 3.5Mi 2.9Gi 2.9Gi
Swap: 0B 0B 0B
user@934cc9d6b341:~$ sar -r 1 5
Linux 6.5.0-1023-aws (934cc9d6b341) 01/17/25 _x86_64_ (2 CPU)
user@934cc9d6b341:~$ du -sh
24K .
14. Shows available and used disk space for mounted filesystems = df -h
user@934cc9d6b341:~$ df -h
Linux Commands
Filesystem Size Used Avail Use% Mounted on
overlay 29G 12G 18G 39% /
tmpfs 64M 0 64M 0% /dev
tmpfs 64M 876K 64M 2% /run
tmpfs 4.0M 0 4.0M 0% /run/lock
shm 64M 0 64M 0% /dev/shm
/dev/root 29G 12G 18G 39% /var/log/amazon/ssm
tmpfs 1.9G 0 1.9G 0% /proc/acpi
tmpfs 1.9G 0 1.9G 0% /proc/scsi
tmpfs 1.9G 0 1.9G 0% /sys/firmware
tmpfs 52M 8.0K 52M 1% /run/user/1001
user@934cc9d6b341:~$ iostat -x
Linux 6.5.0-1023-aws (934cc9d6b341) 01/17/25 _x86_64_ (2 CPU)
Device r/s rkB/s rrqm/s %rrqm r_await rareq-sz w/s wkB/s wrqm/s %wrqm w_await
wareq-sz d/s dkB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
nvme0n1 11.68 589.20 1.49 11.33 5.31 50.46 43.90 4065.71 99.56 69.40 11.04
92.61 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.55 9.80
The Linux kernel interfaces that iotop relies on now require root privileges
or the NET_ADMIN capability. This change occurred because a security issue
(CVE-2011-2494) was found that allows leakage of sensitive data across user
boundaries. If you require the ability to run iotop as a non-root user, please
configure sudo to allow you to run iotop as root.
17. Monitors and tests disk health (part of smartmontools) = sudo smartctl -a /dev/sda
📌 Topics Explained:
Network Management:
Logs Management:
• /var/log/ – The default directory where most system logs are stored.
• journalctl – Accesses logs from the systemd journal for modern systems.
• dmesg – Prints kernel messages, useful for boot and hardware diagnostics.
• tail -f, less, grep – Reads logs in real-time and filters content.
• logrotate – Manages automated log rotation and retention.
• rsyslog, syslog – System logging services used by many Linux distros.
user@de5c3203801d:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.20.0.2 netmask 255.255.0.0 broadcast 172.20.255.255
ether 02:42:ac:14:00:02 txqueuelen 0 (Ethernet)
RX packets 5107 bytes 28224528 (28.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4018 bytes 392433 (392.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
user@de5c3203801d:~$ ss -tuln
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp LISTEN 0 128 0.0.0.0:7681 0.0.0.0:*
14. To check for logs managed by systemd or Monitoring Logs in Real-Time = sudo journalctl -f
17. Displays the first few lines of a log file = tail -5 bootstrap.log
7. Networking Commands
8. Package Management