A Beginner’s Guide to Basic Linux Commands


May 20, 2019


If you are someone who has just transitioned to Linux and still learning the fine points of the book, then this is the right article for you to get your basics right. This article aims to provide readers with a basic understanding of the Linux system. So, before we go any further, let’s understand what Linux is beyond the standard definitions provided in the book. Linux is simply an operating system, just like Windows that is used in a variety of things you see around you. This could be something as small as a light bulb, refrigerator to a big computer data center. In this post, we will look at some basic Linux Commands for beginners to use:

Basic System Commands

  • Pwd: This is the print work directory and will tell you what directory you are in currently.
  • whoami: This will show the current user on the system
  • cd: Will help change directory. Can be used with “/”
  • date: Shows the date on the system
  • Is: Lists out all files and directories you are in.
  • touch: This can be used to quickly create a file and can also be used on existing files.
  • su: refers to the substitute user.
  • rm: removes the file and if you wish to delete a directory, make sure to use “-r”. Ensure that you are careful with this command as a wrong command could end up deleting important files.
  • clear: Clearing out the terminal.

linux-engineer

Looking for a basic Linux hosting plan for your business? Head to LunarPages UK and get one for as low as $4.95 a month.

Reading File contents

  • Make use of “more” and “tail” to read file contents.
  • More filename.txt: This will open up the reader for one to navigate through the file. There are also some additional things that you can use here with this including:
  • Make use of space bar to scroll down.
  • Up and down keys work well to scroll up and down.
  • “g” makes way for “goto” mode. You can use this to enter a line number and proceed to that line immediately.
  • “/” enters search mode. Use it to find whatever you wish in the file. Press “n” to go along to the next found instance of the word.

Intermediate Commands

  • echo: Helps you remove the contents usually text into a file. For example, if you wish to edit or add to an already made text, all you will need to do is “echo, my name is joker >>new.txt” You don’t require separating the spaces with the “\” as there already has been two triangular brackets used.
  • cat: Will help you display the proper contents of a file you wish to open.
  • nano: Denotes keywords with color and also recognizes major languages. Looking to make a new file named “lost.txt”, make sure to insert “nano lost.txt”. Save the file now with Ctrl+X.
  • vi: Use this to add or a modify the current file.
  • sudo: Making changes to some root files? Use “sudo nano alsa-base.conf”. Enter the root command line using “sudo bash” and then punch your password.
  • df: Tells you available disk space in KB’s, if you wish to see this in MB’s, use “df -m”.
  • du: Check the disk usage on your system. Looking to know the space of a particular file then type “df” along with its name.
  • zip, unzip: For extracting and unzipping all zip files.
  • tar: Use it to compress and uncompress different tar archives on the system including .tar, .tar.gz etc.
  • apt-get: Use this to install packages. This will require root permissions and that’s why make use of the sudo command alongside it.
  • uname: This will show all information pertaining to your current system. This includes processor, release date, version etc.
  • ping: It is a network administration software utility used to check the connection of servers on the IP network. This will mean checking the connection to and back and giving information based on the same.
  • hostname: Check your name within your network. Add “hostname -I” to get the IP address as well.

Mastering Linux comes with time and patience but once you do, ensure to get yourself a Linux: Advanced hosting for your business for as low as $49.99.

Useful shortcuts:

  • Ctrl+R: allows you to search the previously typed commands.
  • TAB: Use it to fill within an existing terminal.
  • Ctrl+C: Use this to stop any command.
  • Ctrl+Z: Can be used to force stop any existing command.
  • sudo halt and sudo reboot: Use this to halt and reboot the system.

So, there we have a beginner’s guide to some basic Linux commands that you can use while practicing. Practicing constantly is the key here and there, unfortunately, remains no easy way out to figure this. There however are some patterns that you can relate to and memorize. Practicing it, again and again, is the key to mastering it.