LINUX: ALL About How/what/why Queries ?
2 min readApr 10, 2022
# How to check if the user have sudo access.?-> Use sudo -l command.[ec2-user@ip-172-31-31-16 ~]$ sudo -l
Matching Defaults entries for ec2-user on ip-172-31-31-67:
!visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS",
env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES",
env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",
secure_path=/sbin\:/bin\:/usr/sbin\:/usr/binUser ec2-user may run the following commands on ip-172-31-31-16:
(ALL) NOPASSWD: ALL
(ALL) NOPASSWD: ALLAs per the above output, user ec2-user can run all commands that require sudo access.The access is also updated under /etc/sudoers file.root ALL=(ALL) ALL
khem ALL=(ALL) ALL
# How to check which specific CPU processor process is bind to in Linux.$systemctl show <SeviceName>
e.g:
$systemctl show httpd.serviceIn output look for CPUAffitnity== value ( like 0,1,2 etc )
# How much time the process has been running.
$ps -p <PID> -o etime$ ps -eo cmd,pid,etime | grep testscript.sh
bash script 3206 00:20
grep script 3109 00:00We can see in the last column that process "testscript.sh" has been running from 20seconds.
Now, executing ps again after a few seconds we can see the change in the value.
$ ps -eo cmd,pid,etime | grep testscript.sh
bash script 3506 00:65
grep script 3509 00:00
# What is PID actually associated with each process?
--> PID is a dir/folder name created in a RAM that has more details about the process.
--> We can find more details by going into the /proc filesystem and see the number which is process ID.