Linux – basic commands

Linux is the most used Operating System for servers and the feature that is most fascinating is Command Line. Command Line is a program that is used to run commands and system interpret these commands.

Here are some beginner commands that a new Linux user can use in his learning. In Linux file name and commands are case sensitive.

There are “\” and “/” those are important to understand. “\” is used to escape characters while “/” is directory separator.


“.” is used to represent current directory. if used in start of a file name it hides that file.

“..” – parent directory.

“~” – User’s home directory.

“*” is used to represent one or more characters in a file name. file*.txt can be file2003.txt or file6.txt

“?” represent a single character in a file name. hello?.php can be helloz.php or hello1.php

“[ ]” represent a range of values.

“|” represent pipe. It redirects output of one command to other command – ls | more

“>” redirects output of a command to a new file. If file already exists then it overwrites the file. like ls | output.txt

“>>” redirects output of a command to the end of an existing file. like echo "hello" > file.txt

“<" redirect a file as input to a program. ";" command separator. this operator separates multiple commands on a single line, can be executed on a single line. "&&" is a command separator but it executes second command if first command finished without errors. "&" executes a command in back end. Linux File system. Linux has a tree-structure like folders and files hierarchy. "/" is the root or base level directory. All other directories are child directories of this directory.

Other directories.

“/bin” – binary programs are stored in this directory.

“/boot” – boot loader files

“/etc” – host related files

“/dev” – device or hardware related files

“/lib” – kernel modules, shared libraries

“/home” – user’s personal home files and directories.

“/proc” – process related information

“/root” – root is the admin or super user in a Linux operating system, this directory is home directory of root user.

“/tmp” – temporary files

“/sbin” – system binaries

“/usr” – shareable data

“/usr/bin” – user’s programs are kept here

“/usr/include” – header files of c complied files

“/usr/local” – locally installed files are stored in this directory

“/usr/sbin” – none-vital system files

“/usr/share” – independent data of Linux architecture

“/usr/src” – Linux kernel and source programs

“/var” – variable data such as logs


ls – command is used to list directory contents.

ls -a or ls --all – this command is used to display all hidden contents of a directory or files starting with .

Help for a command.

We can see help for a particular command by typing -h or –help command.

Example: ls -h or grep --help

man command

Manual pages are used to find more help about a command.

Example: ls man

cd – Change directory – This command is used to change current directory.
cd /var/www/html

pwd – print working directory

file – tells about type of file file /bin/ls will output file type as execute able.

cat – displays contents of a file.

head – displays few top lines of a file

tail – displays few last lines of a file

cp – copies a file from one location to other cp file1.html /var/www/html/file1.html

mv – moves a file from one location to other location mv file1.html /var/www/html/file1.html

rm – removes a files rm /var/www/html/first.html

mkdir – makes a new directory

rmdir – removes a directory

which – displays location of a command.

locate – search a file like locate mozilla

ps – list all currently running processes

w – list all logged users and what activity they are doing

id – prints user id and group id

du – displays disk usage

df – displays disk file system usage

top – displays all the processes running in system in real time

free – displays amount of free and used memory in the system.

cat /proc/cpuinfo – displays information about the CPU.

cat /proc/meminfo – display lots of information about current memory usage

uname -a – prints system information to the screen

clear – clears the screen

more – display a file, or program output one page at a time

less – display a file, or program output one page at a time, can be scrolled backwards

grep – Search for a pattern in a file or program output.

lpr – print a file or program output. E

sort – sort a file or program output.

su – allows to switch other user’s account such as switch to root user account.

history – shows history of a command

Tab is used to autocomplete a command.

This was an introduction to Linux and basic commands in next chapters we will explore more advanced topics

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.