Common Linux commands

show remaining memory

df -H

show used memory by path

  • du -sch <path-to-folder>: show all folders
  • du -sh *: show only current depth folders

show users in the machine with encrypted passwords and groups they belong

cat /etc/passwd

show user groups in the machine

cat /etc/group

show the group the current user belong to

group

show active users logged in the machine

w

Ask before removing file

rm -i <file>

History command with number of entries

  • To show 100 entries of history:
history 100

Return code for last command

# You can only use it once, because after running
# echo itself will return 0
echo $?

Check the command origin

## print all matching paths
where <command> # can be used in windows as well
which -a <command>
## exact match
which <command>
 
 
# ------- Modern ways ---------
 
## print single match
type <command> 
 
## print single match and prints exact path
command -v <command>
ls -al <path-to-directory-or-file>