Skip to main content

Basic Linux Shell Commands for Beginners


When opening a shell, your will be logged in with your active account to your home directory (this is usually in /home/user_name).

Note that every command has lots of options available. To see all the manual pages for the specific command, simply type "man <command>". It is important to understand that under Linux operating systems, commands are case-sensitive. This means that "A" is different from "a".

For example if you want to view more info about the mkdir command, type:

man mkdir

Basic File System Commands

Browse the file system

To go through the file system, use: 

  • pwd
    • Prints out on the screen the working directory (eg /etc/ssh)
  • cd
    • changes directory (eg cd .. - goes up one dir; cd etc - enters /etc dir)
  • ls
    • lists the content of the directory
  • mkdir 
    • creates a new directory (mkdir dir_name)
  • touch 
    • creates a new file (touch file_name)
  • rmdir 
    • removes a directory (rmdir dir_name)
  • cp 
    • copies a file/directory (cp source_file destination_file)
  • mv 
    • moves a file/directory - also used for renaming a file or directory (mv old_location new_location or mv old_name new_name)
  • rm 
    • removes files (rm file_name)


Search a file

To search a file, you can use

  • find <search_criteria>
    • (used for filenames)
  • grep <search_criteria)
    • to search for content in the file.


View a file

To view a file, you can use

  • more <filename>
    • will display a file page by page
  • cat <filename>
    • displays all the file
  • head <filename>
    • displays the first lines
  • tail <filename>
    • displays the last lines (useful for example when you want to view the last information logged in a file by the system for example)


Edit a file

To edit a file you must use a built-in editor from the command-line. Generally, this is vi and it's used with the syntax vi <filename>.

vi some_file.txt


Uncompress an archive file

To uncompress an archive (usually tar.gz) you must use the tar command with the syntax tar -xvzf <file_name>.

syntax tar -xvzf some_archive.tar.gz

Print a file

To print a file, use lpr <filename> command. Note that you must have some daemons up and running to manage the printer. Usually this is cups (Common UNIX Printing System) that comes with all major distributions.
To remove a file from printer queue (you can list the queue with lpq command) you can use lprm <filename>.

 Mount and unmount

 To mount/unmount (add in your file system as accessible media) use:

  • mount /mnt/floppy 
    • to mount floppies
  • umount /mnt/floppy
    • unmount floppie
  • mount /mnt/cdrom
    • mount CD-ROMs
  • mount /mnt/cdrom
    • to unmount CD-ROMs

They usually mount automatically, but you could end-up in the situation where you must do it manually. To mount a partition:

  1. First create a directory in /mnt
    1. mkdir /mnt/my_new_drive
  2. then use the mount command where /dev/source is the device (partition) you want to mount in your file system.
    1. mount /dev/source /mnt/my_new_drive

Connect to another server

If you want to connect to a remote host, use the ssh command. The syntax is ssh <hostname>.

ssh username@ipaddress

System management

  • ps
    • shows the current processes running (useful: ps -A shows up all processes)

In the list obtained by using ps command you will see a PID number (Process identification).

This number is required to stop a service or application. Use kill <PID> to stop a task.

  • top 
    • works somehow like the Task manager in Windows. It shows up the system resources, the processes running, average load, etc. Useful is top -d <delay> - sets up the refresh period. You can put any value from .1 (10 ms) to 100 (100 seconds) or even greater.
  • uptime 
    • will display the system's uptime and the load average for that moment, 5 minutes and 15 minutes in the past.

Usually, the load average is calculated as the percent of system resources (processor, RAM, harddisk I/O, network load) used at that moment. 0.37 means that 37% was used. A greater value like 2.35 means that the system had to que some data because it should be 235% faster to compute all without problems. Anyhow, this can be different from distribution to distribution.

  • free 
    • will display information on system's memory
  • ifconfig <interface_name>
    • view detailed information about your network interfaces; generally your ethernet network interface will be named eth0. You can also set up the network settings like ip address or so by using this command (read more with man ifconfig). If something goes wrong, you can also stop/start the interface by using: 
ifconfig <interface_name> up/down

  • passwd 
    • enables you to change your password (passwd own_user or others if you are logged in as root)
  • useradd 
    • command for adding a new user (see man useradd)

Anywhere you are, you cand use the TAB key to autocomplete a filename or command. This will be usefull when getting used to the commands available. You can also hit up arrow and down arrow to scroll through the history of the commands you entered.

You can also use multiple command on one line. Let's say you want to create 3 directories at once. The syntax is:

mkdir dir1 ; mkdir dir2 ; mkdir dir3.

Another useful thing is the pipe command. You can get a command output through another. For example:

man mkdir | tail 

This will display the last lines in the manual pages of the mkdir command.

If at anytime you are asked for the root account (the super-administrator of the system) you can login in temporary with it by using the su command. You should also include the -l (su -l) parameter to switch the home folder and available commands too. Note that you will be prompted for a password too.

To exit the shell type exit or logout


Popular Webmaster Tutorials

WEBSITE TEMPLATE: SLIDING DOORS - Use it as a website template for intros with animation and landing page forms

Greetings fellow webmasters!   Here is a new template for you to use freely on your web development projects. It's called Sliding Doors. This template uses just a little bit of Javascript for its awesome reveal animation effect. Check it out, it's really cool! Check it out here, live preview: Download it on github, here's the link: As always, you can check out all of our free website templates here: Let us know what you think of this new template in the comments bellow. You are welcome to include links to projects you've used this template for.

DAY 1: Become a Webmaster Tutorial - BUILD A WEBSITE IN 10 MINUTES and host it on Github for Free

  Greetings fellow webmasters and soon to become webmasters!   I released my first video in the Become a Webmaster series. With this video I am also updating the Become a Webmaster page with the tutorial for Day 1. Watch the Day 1 video on youtube here:   Read the detailed tutorial on Day 1 here: Day 1 is the most important day in your journey of becoming a webmaster. Here's what I explain in the video and tutorial: How to gather content for your new website How to create a Protonmail account How to create a Github account How to create a repository for your new site How to create the index.html file How to add headings Read the tutorial and then watch the video to follow along.  

How to do research for a website

  Being a Webmaster is a lot of work and research is a big part of it. Like most professions, you need to stay on top of your game. Whether you're building a new website or taking one over, you will need a plan. And a solid plan requires research. If you haven't already, read What is a Webmaster first . Below we have compiled a list of areas of research that you as a Webmaster shoud be very familiar with and actively pursuing. Remember to write down everything you research and the results of your research.   Tools & Service Providers Research Having the right tools for the job is key. Knowing what to use and when will give you the confidence to move forward faster and get things done. As a Webmaster you'll always be asked: where do I register a domain? what's a reliable hosting company? what's your recommendation? Being able to provide knowledgeable advice is your most valuable asset. It's your most valuable asset because it's a source of passive income.