Useful Commands for Linux Beginners- Part 2

Useful Commands for Linux Beginners- Part 2

This article is the continuation of my last post, where I'd listed down a few handy lists of Linux commands for beginners.

Let's go & add some more to that list.

  • alias

The alias is used for assigning another name to Linux commands as per your choice so that you can remember it easily or in a shorter format. It can be used for complex commands to aliased or called by a simple name

Usage:

alias finger=fing  #this will setup fing as another option for finger command.
alias gt="cat {filename} | head -n 5  # after this 'gt' can be used to get top 5 lines
  • curl

The curl command is used to retrieve information and files from URLs.

Usage:

curl https://www.google.com #will output the whole HTML response in the console
curl -I https://www.google.com # will give header info about the request
  • df

The df (abbreviation for disk free) is a standard Unix command used to display the amount of available disk space for file systems on which the invoking user has appropriate read access.

Two of the most useful options are the -h (human-readable) and -x (exclude) options. The human-readable option displays the sizes in Mb or Gb instead of in bytes. The exclude option allows you to tell df to discount filesystems you are not interested in.

Usage:

- df
- df -h
- df -h -x squashfs
  • du

The du (Disk Usage) is used to display the file space allocated to each file and directory contained in the current directory.

Usage:

- du
- du -h # human-readable format
  • free

The free command gives you a summary of the memory usage in your computer. It does this for both RAM and swap memory.

Usage:

free -h
  • diff

The diff command is for comparing two files and list down their differences

Usage:

# y is for side-by-side comparison
# W is for max width in a single row to avoid wrapping
diff -y -W 100 {file1} {file2}
  • passwd

The passwd is used to change the current password for users. The passwd command may be used to change passwords for local accounts and on most systems.

Usage:

passwd #this will prompt you to enter the old password followed by a new password
  • echo

The echo command prints (echoes) a string of text to the terminal window. echo is usually useful to print environment variables that are stored under the system by default like, $HOME, $PATH, etc

Usage:

echo $PATH
  • exit

This will simply close the terminal or end the session for you. exit can be used with the parameter to specify return status. This can be of importance when we want to check the reason for exit in an application

Usage:

- exit  # without parameter
- exit 404  #session will end with return status of 404
  • gzip

The gzip command is used for compressing files. By default, it removes the original file and leaves you with the compressed version. To retain the original and the compressed version, use the -k (keep) option.

Usage:

gzip -k {filename}
  • groups

The groups command tells you the group which you belong to if any.

Usage:

groups {username}
  • man

The man command provides a user manual for any command A.K.A 'man pages'. Interestingly, it leverages less command to make reading user-friendly and easy to scroll and search.

Usage:

man clear  #gives you the info about clear command
  • ps

The ps command gives you running processes in your system currently.

Usage:

- ps       #lists all the running processes
- ps -u {username}   # lists all running processes for the user

That's all folks! The lists for Linux commands are vast and you will only learn when you start implementing them at your work, otherwise, it's not feasible to remember all :)

Thank you for reading this post!