basic linux commands

March 14, 2012 in shell (Command line)

Basic Linux Comands

Here you will find the most common commands that you can you use under the Linux shell.

Do not expect to find all Linux commands here this post contains only what we use in our posts. So this is a good place to find some more information about the commands that we use in our tutorials.

ls -> List of files and folders

Options

-l returns detailed list about files and folders

-g returns detailed list about files and folders without the owners

-a list hidden items

-t sort by time

cd ->Change Directory


Use this command followed by the name of the directory you want to access or the path that leads to the directory.

Example

root@allaboutlinux:# cd var

With this command you will navigate into var directory from root directory

root@allaboutlinux:/var# cd www

With this command you will navigate into www directory from var directory

root@allaboutlinux:/# cd /var/www

With this command you will navigate into www directory from root directory

root@allaboutlinux:/var# cd ..

With this command you will navigate to the parent directory

root@allaboutlinux:/var/www# cd /

With this command you will navigate to the root directory

 

mkdir-> Make Directory

Use this command followed by the name of the directory you want to create or the path that leads to the directory.

Example

root@allaboutlinux:# mkdir newdir

With this command you will create a directory under the root directory named newdir

root@allaboutlinux:# mkdir /var/www/newdir

With this command you will create a directory under the /var/www directory named newdir

 

mv-> Move Directory

Use this command followed by the name of the file/directory you want to move and the path that leads to the destination that your file/directory will moved into.

You can also use that command to rename a file/directory

Example

root@allaboutlinux:# mv newdir /var/www/newdir

With this command you will move newdir from current directory to /var/www. So now under /var/www you will find the newdir

root@allaboutlinux:# mv newdir /var/www/newdir2

With this command you will move newdir from current directory to /var/www and rename it into newdir2. So now under /var/www you will find the newdir witch is now named newdir2

 

cp -> Copy

Use this command followed by the name of the file/directory you want to copy and the path that leads to the destination that your file/directory will copied into.

Example

root@allaboutlinux:# mv newdir /var/www/newdir

With this command you will copy newdir from current directory to /var/www. So now under /var/www you will find a copy of newdir.