You have likely heard of File Transfer Protocol (FTP), File Transfer Protocol over Secure Sockets Layers (FTP/S), and Secure File Transfer Protocol over SSH (SFTP), but did you know that there are some major differences among them? Generally speaking, FTP in its basic form is not secure, FTP/S takes the security up a step in that it allows you to secure all or part of a session (at the cost of speed), and the SFTP protocol is used to ensure that all file transmission will be secure and efficient.


FTP (File Transfer Protocol)

FTP is a very well-established protocol, developed in the 1970s to allow two computers to transfer data over the internet. One computer acts as the server to store information and the other acts as the client to send or request files from the server. The FTP protocol typically uses port 21 as its main means of communication. An FTP server will listen for client connections on port 21.


FTP clients will then connect to the FTP server on port 21 and initiate a conversation. This main connection is called the Control Connection or Command Connection. The FTP client will usually authenticate itself with the FTP server by sending over a username and a password. After authentication, the client and server will typically, through a series of synchronized commands controlled by the Command Connection, negotiate a new common port called the Data Connection over which the file will be transferred. The Control Connection remains idle until the end of this exchange, when it reports that the file transfer has either failed or was completed successfully. The conversation between client and server is performed in plain text—all communication between the two parties is sent unprotected, verbatim, over the internet. This makes FTP very unsecure; it would not be terribly difficult for a third party, such as a Man-in-the-Middle Attacker(MITMA), to steal users’ credentials.


There’s an exception to this rule called One Time Password (OTP), in which the server sends a series of digits to the client server in response to the receipt of the USER command. The client grabs those digits and, using a pre-known algorithm such as ROT13 or MD5, the client will generate a hash of their password along with the series of digits to produce a unique password (used one time, hence the OTP). The client presents this hash to the server, which takes the user’s password, already stored on the server, and uses the same digits. If the hashes of the password match, they are authenticated. This is somewhat more secure because the user’s password does not go over the wire– only a hash of the user’s password– so a MITMA usually can’t reverse engineer the password from the hash.


The need for a Data Connection, and its inherent security loopholes, is a major concern in internet usage today. FTP traditionally requires a block of ports to remain open on either the server firewall or the client firewall to aid with the creation of Data Connections. For security reasons, companies are limiting the number of ports in their publicly facing firewalls and looking for alternate solutions in order to keep ports closed and information secure.


SFTP (Secure File Transfer Protocol)

SFTP (Secure File Transfer Protocol) is a relatively new protocol developed in the 1990s, which allows for the transfer of files and other data over a connection that has previously been secured using the Secure Shell (SSH) protocol.  While similar to FTP/S in that both protocols communicate over a secure connection, that’s basically where the similarities end.


Unlike FTP, the SFTP protocol is packet-based instead of text-based. Where FTP might send a command such as “DELE file.txt,” SFTP would send a binary 0xBC and then “file.txt.” The key difference is that by sending less data, the SFTP protocol is faster over the long-term as less data is crossing the wire.


Another difference is that with SFTP, file transfers are performed in-line over the main Control Connection, thus eliminating the need to open a separate Data Connection for transfers. This has many benefits. First, by re-using the main connection, no other connections are opened between the client and the server, resulting in a single secure, efficient connection through firewalls.


Since SFTP runs over SSH, it is inherently secure. There is no non-secure version—the encryption cannot be triggered or turned off using AUTH commands, as in FTP/S. This is a plus for system administrators who are trying to enforce corporate security policies.


Another difference is that most versions of SFTP are able to deliver a much richer and more detailed set of data about the files, such as the permissions, date, time, size, and other information not normally available to FTP, thanks to the more robust request protocol of the SFTP.

     tcpdump is a most powerful and widely used command-line packets sniffer or package analyzer tool which is used to capture or filter TCP/IP packets that received or transferred over a network on a specific interface. It is available under most of the Linux/Unix based operating systems. tcpdump also gives us a option to save captured packets in a file for future analysis.

See the list of interfaces on which tcpdump can listen:

Listen on interface eth0:

Listen on any available interface (cannot be done in promiscuous mode. Requires Linux kernel 2.2 or greater):

Be verbose while capturing packets:

Be more verbose while capturing packets:

Be very verbose while capturing packets:

Be verbose and print the data of each packet in both hex and ASCII, excluding the link level header:

Be verbose and print the data of each packet in both hex and ASCII, also including the link level header:

Be less verbose (than the default) while capturing packets:

Limit the capture to 100 packets:

Record the packet capture to a file called capture.cap:

Record the packet capture to a file called capture.cap but display on-screen how many packets have been captured in real-time:

Display the packets of a file called capture.cap:

Display the packets using maximum detail of a file called capture.cap:

Display IP addresses and port numbers instead of domain and service names when capturing packets (note: on some systems you need to specify -nn to display port numbers):

Capture any packets where the destination host is Display IP addresses and port numbers:

Capture any packets where the source host is Display IP addresses and port numbers:

Capture any packets where the source or destination host is Display IP addresses and port numbers:

Capture any packets where the destination network is Display IP addresses and port numbers:

Capture any packets where the source network is Display IP addresses and port numbers:

Capture any packets where the source or destination network is Display IP addresses and port numbers:

Capture any packets where the destination port is 23. Display IP addresses and port numbers:

Capture any packets where the destination port is is between 1 and 1023 inclusive. Display IP addresses and port numbers:

Capture only TCP packets where the destination port is is between 1 and 1023 inclusive. Display IP addresses and port numbers:

Capture only UDP packets where the destination port is is between 1 and 1023 inclusive. Display IP addresses and port numbers:

Capture any packets with destination IP and destination port 23. Display IP addresses and port numbers:

Capture any packets with destination IP and destination port 80 or 443. Display IP addresses and port numbers:

Capture any ICMP packets:

Capture any ARP packets:

Capture either ICMP or ARP packets:

Capture any packets that are broadcast or multicast:

Capture 500 bytes of data for each packet rather than the default of 68 bytes:

Capture all bytes of data within the packet:

Find Linux Files by Name or Extension

Use find from the command line to locate a specific file by name or extension. The following example searches for *.log files in the /home/username/ directory and all sub-directories:

Common Linux Find Commands and Syntax

find expressions take the following form:

  • The options attribute will control the behavior and optimization method of the find process.
  • The starting/path attribute will define the top level directory where find begins filtering.
  • The expression attribute controls the tests that search the directory hierarchy to produce output.

Consider the following example command:

This command enables the maximum optimization level (-O3) and allows find to follow symbolic links (-L). find searches the entire directory tree beneath /var/www/ for files that end with .php.

Basic Examples

Command Description
find . -name testfile.txt Find a file called testfile.txt in current and sub-directories.
find /home -name '*.jpg Find all .jpg files in the /home and sub-directories.
find . -type f -empty Find an empty file within the current directory.
find /home -user exampleuser -mtime 7 -iname ".db" Find all .db files (ignoring text case) modified in the last 7 days by a user named exampleuser.

Options and Optimization for Find

The default configuration for find will ignore symbolic links (shortcut files). If you want find to follow and return symbolic links, you can add the -L option to the command, as shown in the example above.

find optimizes its filtering strategy to increase performance. Three user-selectable optimization levels are specified as -O1-O2, and -O3. The -O1 optimization is the default and forces find to filter based on filename before running all other tests.

Optimization at the -O2 level prioritizes file name filters, as in -O1, and then runs all file-type filtering before proceeding with other more resource-intensive conditions. Level -O3 optimization allows find to perform the most severe optimization and reorders all tests based on their relative expense and the likelihood of their success.

Command Description
-O1 (Default) filter based on file name first.
-O2 File name first, then file-type.
-O3 Allow find to automatically re-order the search based on efficient use of resources and likelihood. of success
-maxdepth X Search current directory as well as all sub-directories X levels deep.
-iname Search without regard for text case.
-not Return only results that do not match the test case.
-type f Search for files.
-type d Search for directories.

Find Files by Modification Time

The find command contains the ability to filter a directory hierarchy based on when the file was last modified:

The first command returns a list of all files in the entire file system that end with the characters conf and have been modified in the last 7 days. The second command filters exampleuser user’s home directory for files with names that end with the characters conf and have been modified in the previous 3 days.

Use Grep to Find Files Based on Content

The find command is only able to filter the directory hierarchy based on a file’s name and meta data. If you need to search based on the content of the file, use a tool like grep. Consider the following example:

This searches every object in the current directory hierarchy (.) that is a file (-type f) and then runs the command grep "example" for every file that satisfies the conditions. The files that match are printed on the screen (-print). The curly braces ({}) are a placeholder for the find match results. The {} are enclosed in single quotes (') to avoid handing grep a malformed file name. The -exec command is terminated with a semicolon (;), which should be escaped (\;) to avoid interpretation by the shell.

Before the implementation of the -exec option, this kind of command might have used the xargscommand to generate a similar output:

How to Find and Process Files Using the Find Command

The -exec option runs commands against every object that matches the find expression. Consider the following example:

This filters every object in the current hierarchy (.) for files named file.conf and runs the chmod o+rcommand to modify file permissions of the find results.

The commands run with the -exec are executed in the root directory of the find process. Use -execdir to execute the specified command in the directory where the match resides. This may alleviate security concerns and produce more desirable performance for some operations.

The -exec or -execdir options run without further prompts. If you prefer to be prompted before action is taken, replace -exec with -ok or -execdir with -okdir.

How to Find and Delete Files in the Linux Command Line

Use this option with extreme caution.

Add the option -delete to the end of a match expression to delete all files that match. Use this option when you are certain that the results only match the files that you wish to delete.

In the following example, find locates all files in the hierarchy starting at the current directory and fully recursing into the directory tree. In this example, find will delete all files that end with the characters .bak:


sed linux

   What is SED ? –> Birth of SED

     Sed command can be used to delete or remove specific lines which matches a given pattern or in a particular position in a file. Here we will see how to delete lines using sed command with various examples.

The following file contains a sample data which is used as input file in all the examples:

Sed Command to Delete Lines – Based on Position in File

In the following examples, the sed command removes the lines in file that are in a particular position in a file.

1. Delete first line or header line

The d option in sed command is used to delete a line. The syntax for deleting a line is:

Here N indicates Nth line in a file. In the following example, the sed command removes the first line in a file.

2. Delete last line or footer line or trailer line

The following sed command is used to remove the footer line in a file. The $ indicates the last line of a file.

3. Delete particular line

This is similar to the first example. The below sed command removes the second line in a file.

4. Delete range of lines

The sed command can be used to delete a range of lines. The syntax is shown below:

Here m and n are min and max line numbers. The sed command removes the lines from m to n in the file. The following sed command deletes the lines ranging from 2 to 4:

5. Delete lines other than the first line or header line

Use the negation (!) operator with d option in sed command. The following sed command removes all the lines except the header line.

6. Delete lines other than last line or footer line

7. Delete lines other than the specified range

Here the sed command removes lines other than 2nd, 3rd and 4th.

8. Delete first and last line

You can specify the list of lines you want to remove in sed command with semicolon as a delimiter.

9. Delete empty lines or blank lines

The ^$ indicates sed command to delete empty lines. However, this sed do not remove the lines that contain spaces.

Sed Command to Delete Lines – Based on Pattern Match

In the following examples, the sed command deletes the lines in file which match the given pattern.

10. Delete lines that begin with specified character

^ is to specify the starting of the line. Above sed command removes all the lines that start with character ‘u’.

11. Delete lines that end with specified character

$ is to indicate the end of the line. The above command deletes all the lines that end with character ‘x’.

12. Delete lines which are in upper case or capital letters

13. Delete lines that contain a pattern

14. Delete lines starting from a pattern till the last line

Here the sed command removes the line that matches the pattern fedora and also deletes all the lines to the end of the file which appear next to this matching line.

15. Delete last line only if it contains the pattern

Here $ indicates the last line. If you want to delete Nth line only if it contains a pattern, then in place of $ place the line number.

Note: In all the above examples, the sed command prints the contents of the file on the unix or linux terminal by removing the lines. However the sed command does not remove the lines from the source file. To Remove the lines from the source file itself, use the -i option with sed command.

If you dont wish to delete the lines from the original source file you can redirect the output of the sed command to another file.

In CentOS 7 the process called Firewalld .

 FirewallD is front-end controller for iptables used to implement persistent network traffic rules. It provides command line and graphical interfaces and is available in the repositories of most Linux distributions.

If you want to know more about it follow the link above.



How we Disable Firewalld:
  • login as root user and run the command bellow:

How to Stop the Firewalld:
  • login as root user and run the command bellow:

Check the Status of Firewalld
  • login as root user and run the command bellow:

Quite simple and easy but you need to have other ways of protecting after disabling the firewall.

linux swappiness


We learned in our last tutorials how to add SWAP and what is actually SWAP space used for. If you haven`t read this tutorial you can find it here – How To Add Swap to Linux Box.

But SWAP space comes with full bag of tricks and it can impact your System depending on the configuration you apply to it.

In out /etc/sysctl.conf file we have a parameter called swappiness that controls when your system should start using the SWAP space.

OK what do we mean by control ?

  • when ever the total used memory reached the swappiness  parameter value the system will start using the SWAP space. This is not so good when this parameter is set to its default value of 60.

Swappiness  holds a value between 0 and 100 that represents a percentage.

So when we have swappiness  set to 60 it means that when you system used 60% of its memory it will start swapping.

How can we change it ?

  • to change the value of the swappiness  parameter you need to use the sysctl command:

  • this will only be available until the next reboot.

To make this change permanent you need to edit the  /etc/sysctl.conf file.

There other parameters that can be edited but they go beyond the scope of this tutorials.


i hope this was helpful



In this tutorial we will see how we can add SWAP space to our Linux box and also understand the use of SWAP space.

What is Swap ?

Swap is an area on a hard drive that has been designated as a place where the operating system can temporarily store data that it can no longer hold in RAM.

Basically, this gives you the ability to increase the amount of information that your server can keep in its working “memory”. The space on the hard drive will be used mainly when space in RAM is no longer sufficient for data.

Very important to understand is that the information written to disk will be slower than information kept in RAM, but the operating system will prefer to keep running application data in memory and use swap for the older data. Overall, having swap space as a backup plan when your system’s RAM is almost done and swap space will save your skin.


So now that we know what is SWAP and why we use it let`s see how we can get information about our system SWAP, how we can add more SWAP or even remove SWAP space.

1.See if you have SWAP:

We can see if the system has any configured SWAP by typing:

  • no SWAP here !!!

Also free command with option -m can tell use about our SWAP

  • As you can see our total swap space in the system is 0.

2. Add SWAP

Before you add SWAP you need to make sure you have the disk space on your host, df command with option -h is a good candidate for this task.

  • ok we got some space left.

SWAP space can be added using the dd command or fallocate command.

dd           –  pre allocates a portion of the disk

  • you can use dd to write zeros to the file from a special device in Linux systems located at /dev/zero that just spits out as many zeros as requested.(pretty smart 🙂 )

fallocate –  creates a file of a pre allocated size instantly, without actually having to write dummy contents.


Create using dd:

  • the command will spit 1024 mb (zeross) into the file /SWAPfile

  • SWAP file create

Create using the fallocate:

  • this way is instant file allocation.

3.Enabling the Swap File

At this point we have the file created and we need to hand it to our operational system for use. Before we go ahead and do this we need to make sure this file can be read only by the root user.

Change file permissions:

Setup SWAP by using the mkswap command:

Make SWAP available now:

Verify that SWAP is there:


Great our system has SWAP space now but we need to make is permanent because at this point if we reboot the system the swap space will be lost.

What we need to do is add a new entry in out /etc/fstab file.

  • this will make sure that when reboot your system the swap file will be “mounted”.

And we are done! There are more to add about Linux SWAP space but we will touch base about this on the next Tutorial – Manage SWAP space Settings in Linux


sudo linux

There are two ways to run administrative applications in Linux.

1- You can either switch to the super user root with the su command.

2 – Use sudo.

 What is sudo ? 

Is a program that allows users to run programs with the security privileges of another user, by default the superuser.

So let us add a new user and grant him sudo privileges

The first step is to add a new user. New users, by default, are unprivileged. This means that they will only be able to modify files in their own home directory, which is what we want at this stage.

To create a new user user adduser commad

  • so we have create our user called userJoe(Joe is a very important user in our big company).

Let`s give userJoe a password by using the passwd command 

  • you will be asked to type the password two times.


Grant Administrative Privileges to userJoe

Well at this point we have userJoe ready to receive elevated privileges.

To make userJoe part of the sudoers group we can use the visudo command or edit the /etc/sudoes file.

Logged in as root run the visudo command:

When you type this command, you will be taken into a text editor session with the file that defines sudo privileges pre-loaded. We will have to add our user to this file to grant our desired access rights.

Find the part of the file that is labeled “User privilege specification”:

– so we need to add userJoe as replica of the root user.

Save and close.

Now, when you are logged in as your userJoe user, you can execute a certain command with root privileges by typing:

You will be prompted to enter your user’s password (not the root user’s password but userJoe password). The command will then be executed with elevated access.

And is done userJoe is now ready ot take on the world 🙂


We can also run the following command that will edit the /etc/sudoers file 

  • /etc/sudores file is read only by default, so you can alter that, push the userJoe rule as a sudo user and change back the file read only type.


  • in this last command we specify that userJoe can  switch to sudo without having to punch in his password due to the NOPASSWD option.

hope this was useful…

install ssh

In this short tutorial we will see how to install and configure ssh server or client under CentOS Linux operating systems !

What is ssh ? 

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Secure Shell provides strong authentication and secure encrypted data communications between two computers connecting over an insecure network such as the Internet.

CentOS packages required:

  • openssh-clients : The OpenSSH client applications
  • openssh-server : The OpenSSH server daemon


How to install them ?

Use yum package installer:

  • quite easy, the -y will advance the agree part.

Start and configure

  • chkconfig will set sshd to start on reboot.

Verify the service is running

All ssh traffic on your host by editing the firewall rules

  • or edit the file and type it in.
  • this rule will open for all hosts.

If you wanna restrict access use the bellow code:

  • make sure you point to the right ip/mask

Note: – you need to restart you firewall after you edit the ip rules.


More advanced ssh configurations can be done by editing the  /etc/ssh/sshd_config file 

Configuration changes such as :

  • restrict root access by password.
  • restrict a specific user
  • change ssh port

-more configurations can be applied and changed as per your need.


hope this was useful..

Simple and easy way to count the columns in cvs files in Linux using sed utility.
Ous csv file is called data.csv and contains the following

 Count the numbers of columns.


Also as we can use awk for this task as Robert McAllister stated.


In this short article we will see how we can split a file in Linux using a STRING as the split delimiter.

I will use this file as example :

The script does not make any sense, all i need is the string i will use to separate the content into different files.

For the split task i will use the awk commnad

  • we will look for the “INSERT INTO” string.

The syntax is as bellow:

After you run the command you will end-up with as many new out”n”.txt files as you have  “INSERT INTO” string findings.

See output results:

I hope this was useful.


Os tutoriais são destinada para os administradores de Banco de Dados.
Sintase livre para usar los como exemplo. não sera responsabilizado por quaisquer danos usando esses tutoriais.

  • To start the sshd daemon, type the following at a shell prompt:
  • If you want the daemon to start automatically at the boot time, type:
  • This will enable the service for all runlevels.

  • To stop the running sshd daemon, use the following command:
  • How to Disable Selinux

    With Selinux enabled you may have problems starting the Oracle client library. This is because the SELinux feature does not allow the Oracle library to be loaded.

    Be aware that by disabling SELinux you will be removing a security mechanism on your system.

    To work around this problem, you will need to disable SELinux on your system.

    To disable SELinux permanently, edit the file /etc/selinux/config and change “enforcing” to “disabled”.

    After editing the file save it and exit.

  • 1- Find and edit the following file “/etc/hosts”
  • 2- Edit /etc/sysconfig/network
  • Save and close the file.

  • 3- Type the following command:
  • Your new host name should be set now.

    In this article we will show you how to setup password-less log in using ssh keys to connect to remote Linux servers without entering password. Using Password-less log in with SSH keys will increase the trust between two Linux servers for easy file synchronization or transfer.

    SSH Password-less log in is one of the best way to automate tasks such as automatic backups with scripts, synchronization files using scp and remote command execution.

    Let’s follow the steps in creating the password-less connection.

  • 1- First you need to install SSH-client .
  • 2- Generate a pair of public keys.
  • To do so you need to use the commands:(just press enter until the process finishes)

  • 3- Set directory permission
  • Next make sure you have correct permission on .ssh directory:

  • 4- Create the file authorized_keys inside .ssh folder and copy the content of the inside of it.
  • This will hold the used keys for password-less connection.

  • 5- Change the permission on authorized_keys.
  • 6- Do the same on the other server where you want to connect password-less.
  • Just follow the first 5 steps.

  • 7- Copy public key from one server to another and place it inside the authorized_keys file.
  • Then try to connect to the server. You will be asked if you want to continue and the host will be added to to the known_hosts file.

    And that is it – ssh password-less is configured.

    Go to
    page and download the desired ubuntu version.

    After you download or you create de CD or a bootable USB stick create a new Virtual Machine.

  • Open Oracle VirtualBox and press the NEW button and start creating a new virtual machine.

  • Choose next :

  • Give a name to your new virtual machine ,choose the operational system (Ubuntu), choose the version depending on your windows OS (i recommend 32 bits).

  • Give it at least 1 gb of RAM (don’t give more then half of your host RAM).

  • Create a new disk that will host the Ubuntu OS.

  • Choose the VDI option.

  • This is up to you if you want to have fixed size or dynamic size allocation.

  • I prefer fixed size with a minimum of 20 GB as i use this vistual machine for learning purpuse.

  • Choose the size of the disk you want to allocate to your Ubuntu OS.

  • My choise is 20 GB.Make sure you have the space on you local disk.

  • Check the summary detailes and create the Virtual Disk that will host the Ubuntu OS.

  • This can take some time depending on the size of the created disk.

  • Great we have a Virtual Machine created, now let’s configure the settings.

  • Select the Machine and press the Settings button.

  • Go to the System menu and disable the Hardware virtualization.

  • Go to the Display menu and give some 36 mb to video memory.

  • Press ok , select the Virtual machine and press Start button.

  • Press Next.

  • Choose the media that contains the Ubuntu OS, or if you have burned a cd point to the CD media orto the bootable USB stick if one is created.Press next and follow the installer steps.

  • For more installation detailes go to this


    , as is the official Ubuntu installation guide.And check the fourth step.

    In the next tutorial we will learn how linux is designed and we will learn the basics of linux terminology.

    For more information leave you question or comments on the page or contact me using the Contact Page.

  • This is a very useful and powerful Linux tool, every System Administrator will take full advantage of crontab futures.

    Why is Crontab important and useful ?

    Well we can create routines and maintenance jobs that will run in the background automatically, following the desired schedule.




    • [-e] – this option is used when we want to edit the current crontab file, it will open the crontab file into a editor.
    • [-l] – this option is used when we want to list and see the content of the crontab file.
    • [-r] – this command will remove the crontab file.
    • [-u] – this option will point to who’s crontab file will be edited, if this option is not used by default the current user crontab file will be used.
    • [-v] – will show the last time the crontab file was edited.

    Crontab Format

    • this is an example of a crontab content

    The crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

    We can also use the  *(wildcard)

    – witch is a wildcard(can take all the values contained in the current field is encountered).

    How to view or alter the crontab file of another user

    For this task you need to be root user.


    -this way we can list the crontab file of the named user.

    Crontab Restrictions

    You can execute crontab if your user name appears in the file “/usr/lib/cron/cron.allow“.If that file does not exist and your name does not appear in the file “/usr/lib/cron/cron.deny” you can use crontab.

    We cannot create a job in the crontab file that will run more often then every 60 seconds.

    More examples of crontab commands

    1- How to view the crontab of another user
    -you need to have administrator privileges in order to use the -u option.

    2- Remove/Un-schedule all crontab jobs.

    3- Create a job that will run every minute 

     4- Create job that will run every 5 minutes


    Even better now that you know how crontab works you can use the tool below to generate you own crontab commands

    The corntab generator belongs to

    What is I/O Redirection ?

    Is the manner we can manipulate the INPUT/OUPUT of a command.Every correct command will have an output so with redirection we can send the output to file/files or even to the input of another command.

    Standard Output

    Most command will have their outputs displayed on the terminal prompt.So to redirect the output content to a file we will use the ”


    ” (bigger then).



    We can see that by doing the “ls” command we get a list of the files that are in the working directory.To get this output stored into a files we will use the “>
    ” after the “ls”(list) command followed by the names of the file that will receive the data.


    : if you repeat the command above the “redirect” file will be overwritten.

    To avoid overwriting the file but still make a redirect using him we will use the ”


    ” command:

    We can see in this example that by using the ”


    ” command the second output redirection was just added to the existing data in the “redirect” file.

    Standard Inputs

    By default standard input get their content from the keyboard , but as well it can be redirected. To redirect a standard input we will use ”


    ” command.


    So, we can see that by using the content of the file “redirect” we create input for our “sort” command.We see that the order of the content will be altered after applying the “sort” command over the “redirect”file.

    Now let’s see how we will redirect the output of the sorted input content into a new file called “sorted_redirect”

    Well this is a bit more complex, but you need to understand this so we can continue with out tutorials.

    A better description for this is this drawing:

    An image can express 1000 word.

    Play with the redirect commands and try to use them in all possible ways.Redirect is of great help in daily work.

    Linux Pipes ”


    One of the most used tools in Linux when working with redirecting I/O.With the help of pipes the standard output of one command can become the input for another command and so on depending on the complexity of the command.

    Examples of the use of Pipes ”



    ls -l ”


    ” less

    -this command will create a scrolling output.

    -displays the 10 newest files in the current directory.

    -this command will sort the directories from the largest to the smallest.

    -Displays the total number of files in the current working directory and all of its sub-directories.

    – will dispay all the output lines that have “pattern” inside .

    Filters in Linux

    Filter are the programs that can be used with pipes to process the content information.

    Some of the most used Filters are :

    (i will list my favorites, and we will give examples of them in the future tutorials)

  • 1- grep -Examines each line of data it receives from standard input and outputs every line that contains a specified pattern of characters.
  • 2- awk -An entire programming language designed for constructing filters. Extremely powerful.
  • 3- tail -Outputs the last few lines of its input. Useful for things like getting the most recent entries from a log file.
  • 4- head -Outputs the first few lines of its input. Useful for getting the header of a file.
  • 5- sort -Sorts standard input then outputs the sorted result on standard output.
  • Linux is multi tasking OS and it executes multiple processes simultaneous. One of the best futures of working at the terminal line is that we can easily manipulate this type of activity(processes).

    Why is important to control the processes in Linux

    Well, as administrator you will have to know and understand the Linux Processes and what types they are so you can manipulate then as you like.

    By manipulating we reefer to the priority of running processes and termination of that processes.

    What is Running Processes ?

    Also called ‘running instance’ or ‘program’ the process is a program in execution. The processes consists in executing program code, resources such as open files, internal data, an address space, one or more threads of execution and a data section containing global variables.

    Every process has it’s own descriptors that keeps the information used to track the procces in the memory.

    We will not look deep into the processes since this is a wide area in the Linux OS. We are going to describe and explain how we can see and manipulate the running processes.

    How to see/list all the Running Processes ?



    command is used to list all the Running Processes.



    • [


      ] – show information about all processes most frequently requested.
    • [


      ] – show information for all processes.
    • [


      ] – show information about every process now running.
    • [


      ] – show full listing.

    Note: this are not all the options.

    -for all the option of the ps command use “ps man” to list them in at the terminal line.

    Examples of using the ps command

    List all the running processes:

    List all the running processes with full format listing:

    List all the running processes for a specific user:

    -as you can see the list of running processes for user “wannabedba” is diferent from the “root” user.

    List all the running processes details for a specific processes:


    The “ps” command will just show us an image of the actual running processes, so this is just a snapshot of the current processes.

    How do we list all the current processes in real time

    The command used for such task is the



    It produces an ordered list of running processes selected by user-specified criteria,and updates it periodically.

    This command is very useful because we can see who is using more system resources.

    Another command that we can use to get real time running processes details



    command was designed to replace the Unix program uses color to give a more detailed visual and also it provides a more convenient cursor-controlled interface for killing processes.

    If you do not have it on your OS just install it using the “apt-get” command.

    -this command is quite complete and it easy to use and understand and more important is free.

    To get more information about this great linux tool go to and make sure you share this with your friends and colleagues.

    Now let’s go back to TOP command and see some useful example

    The point of this examples is for you to understand what is going on behind the “closed doors”.We could do all off the following examples using the HTOP tool witch is more intuitive and easy to use but none the less is less used and tested since is a young tool.


    Examples of top commands

    For you to understand the content of the output listed by the “top” command we will explain every line listed on the screen.

    First line

    The second line

    The third line

    The forth and fifth lines

    As we see in the picture here we have the total memory, used memory ,free memory and cached and buffer memory listed.

    The header of the processes information detailes

    Great, now that we have described the content of the “top” output, let’s see how we can interact with it.

    We will learn how to see the output of the top command in more forms:

    After the top command was executed and we have the output just by pressing one of the following keys we will get different outputs:

    • M Sort by memory usage
    • P Sort by CPU usage
    • T Sort by cumulative time
    • z Color display
    • k Kill a process -when using this option a prompt will appear asking for the PID(process ID)
    • q quit

    Options for the top command

    [-u] – with this option we can monitor the process information by UID(user id).


    [-p] – with this option you can monitor the information by PID(process ID).


    – where 3306 is the PID for the process.

    We also can use it for monitoring more then one process:


    -just by using the -p option more then once

    Or even more easy

    -this will show the same output.

    [-n] – it will update the output this (-n) many times.


    – the top output will be displayed 10 times before the top will exit.

    [-d] – it set the interval between output update.


    – this command will tell the top command to update the output every 3 seconds.

    Killing a process

    After we have seen how to list and monitor our processes let’s see hoe we can kill a process.

    To do so we will create few processes and we will “play”/”kill” with them.

    We will use the

    xload “&”

    witxh is a program that displays a periodically updating histogram of the system load average.


    – “xload” program is displays a periodically updating histogram of the system load average. -the “&” sign will make the program run in the background.

    So we are going to create a dummy process just to show you guys how to interact and how to kill a process:

    You can see in the image that we have 3 processes running and we add a new one by opening a “xload” window just to simulate a new process.

    See that by using the “ps” command we get a list of processes running on the OS, here we have now 4 processes and one of them is out new “xload” process and if hold an PID(process ID) in our case 1734.

    In the next step we will eliminate this processe by using the kill command as you can see in the picture.

    See in this picture that the process we have just killed is gone, no longer is he running.

    Killing more then

    Now we will see how we can kill one or more processes in one line(with one bullet).See here we have created 3 new processes using our xload command.And we will list them using the ps command.

    Next step is : kill them all :).

    Now here is the exit of the kill command, see all the 3 processes are no longer alive(running).


    -if the process won’t die/stop use the following option of the kill command:

    – the [-9] -causes the immediate termination of the process.It’s like an immediate shutdown.

    How To Customize the Prompt

    Most Linux systems when you open a terminal line have a default prompt in one color (usually gray) that tells you your user name, the name of the machine you’re working on by default.

    The prompt can show all types of information such as : time, date, load,number of users, etc…

    The prompt is defined in the variable called “PS1”, to see how you actual prompt code looks like do this command :

    echo $PS1

    – so this bunch of signs,lines and numbers are the code that will output the content of you prompt line .

    How can i alter or change my Prompt in Linux ?

    -well, remember out variables tutorial and all that stuff is time to use all that .

    – so now let’s alter the PS1 variable so we can change our prompt look;

    -nice you see that we have used the “export” command to overwrite the value of PS1 variable.


    -this change will be available until we close this session.

    How can i alter or change my Prompt in Linux permanently

    -remember our .bashrc file ? So he is the answer to our question.

    Let’s go and edit this file to out needs:

    Look of the .bashrc file and open it with any text editor you have:

    Look inside this file the line “title to [email protected]” and alter the content of the PS1 variable , put what ever you want.

    Note-if you are new to Linux make sure you save the string you are about to alter, so you can go back to it anytime you want.

    After you have altered and saved the altered .bashrc file do the source ~/.bashrc command so that the changed should be applied.

    And there you go your prompt has a new look.

    Prompt creating command options

  • [a] – an ASCII bell character (07)
  • [ d] – the date in “Weekday Month Date” format (e.g., “Tue May 26”)
  • [ e] – an ASCII escape character (033)
  • [ h] – the hostname up
  • [ j] – the number of jobs currently managed by the shell
  • [ l] – the basename of the shell’s terminal device name
  • [ n] – newline
  • [ r] – carriage return
  • [ s] – the name of the shell, the basename of $0 (the portion following the final slash)
  • [ t] – the current time in 24-hour HH:MM:SS format
  • [ T] – the current time in 12-hour HH:MM:SS format
  • [ @] – the current time in 12-hour am/pm format
  • [ u] – the username of the current user
  • [ v] – the version of bash (e.g., 2.00)
  • [ V] – the release of bash, version + patchlevel (e.g., 2.00.0)
  • [ w] – the current working directory
  • [ W] – the basename of the current working directory
  • [ !] – the history number of this command
  • [ #] – the command number of this command
  • [ $] – if the effective UID is 0, a #, otherwise a $
  • [ nnn] – the character corresponding to the octal number nnn
  • [ \] – a backslash
  • [ [] – begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
  • [ ]] – end a sequence of non-printing characters
  • Color Codes Options

  • Black – 0;30
  • Dark Gray – 1;30
  • Blue – 0;34
  • Light Blue – 1;34
  • Green – 0;32
  • Light Green- 1;32
  • Cyan – 0;36
  • Light Cyan – 1;36
  • Red – 0;31
  • Light Red – 1;31
  • Purple – 0;35
  • Light Purple – 1;35
  • Brown – 0;33
  • Yellow – 1;33
  • Light Gray – 0;37
  • White – 1;37
  • Examples of how we can alter the Linux Prompt

    1-Show just the name of the user and the host name:

    – this will show the following:

    2-Show host name and the actual working directory:

    – this will show the folowing:

    3-Show hostname and time :

    – this will show the following:

    4-Show the prompt with a different color then grey:

    This can be difficult to understand but i will put it in a easy way for you guys:

    Creating a PS1 values with colors has a certain syntax and order:

  • e

    – indicates the begining of the color.

  • {color}m

    – the “color” represent the color code shown early in the tutorial followed by “m” letter.

  • e[m

    – indicates the end of the color.
  • Syntax


    color code you want

    and what ever you want to be displayed(host,time,user,etc..)


    You can add more option, but it will be displayed with the default color

    What are Linux groups ?

    A group is a set of users, created to share files and to facilitate collaboration. The system administrator can add new groups and give users membership to the different groups, according to the users’ organizational needs. On a Linux system, you’re always a member of at least one group.

    Groups are used in Linux for access control. The only user that has full access is the super user (ROOT).

    Where we can find the group information ?

    The /etc/group is the file that defines the groups on the system.

    To display the group of a user we will use the command :

    – if we do not use the “user name” option the current user group will be displayed.

    How to create a new group in Linux

    To create a new group we will use the “groupadd” command :

    How can we add a new member to a group in Linux

    For this we will use the “gpasswd” command :


    Except for the -A and -M options, the options cannot be combined.

    The options which apply to the gpasswd command are:

  • [-a] -add user – Add the user to the named group
  • [-d] -delete user – Remove the user from the named group
  • Examples

    – this command will add the user named “user1” to the group named “group1”.

    – this command will remove the user named “user1” from group named “group1”. But will not delete the user.

    How drop/delete a group in Linux

    For this we will use the “groupdel” command :

    – the group has to exist in order to drop it :).

    How to give permissions to groups in Linux

    After a group is created it has no permissions on anything so we need to create some for them.

    For this we will use the “groupmod” command :

    The groupmod command modifies the definition of the specified GROUP by modifying the appropriate entry in the group database.

    groupmod – modify a group definition on the system


    groupmod [options] “group name”


  • [-h] – Display help message and exit.
  • [-n] – Change name of a group.
  • Example

    – this command will change the name of the group “group1” to “groupX”.

    For now this all about groups, in future tutorials we will go in more details about groups and how to set out default groups.

    Echo command

    Echo command is used to display text or the values of a variable.



  • [-n] -Do not output the trailing new line.
  • [-e] -Enable interpretation of the following backslash escaped characters in the strings.
  • [a] -alert (bell).
  • [b] -backspace.
  • [c] -suppress trailing new line.
  • [n] -new line.
  • [r] -carriage return.
  • [t] -horizontal tab.
  • [\] -backslash.

  • Note

    – to use this options we need to use the -e after the echo command and before the option.

    Examples of echo command use

    Simple echo, output’s a string:

    Show a Environment Variable using echo:

    It will show the values stored into HOME variable, in our case the HOME variable stores the path to the home of current user.

    It will print a new line for us, everything that is after the n will be outputed on another line.

    It will add a horizontal tab space to our line in the place where the t is placed.

    ROOT USER(super user)

    The root user is called a superuser because it has powers far beyond those of normal users.As root, you can access files and change the system in ways other users cannot.But you can also wipe out your entire hard drive in just ten keystrokes.

    The “root” user should not be used normally. This user should be used only when we plan do do some changes to our OS that require special permission. So is better to create a user for your daily jobs that you will use, and avoid using the root user.

    Creating a user in Linux

    In linux new users are created by the superuser “root”.

    Every user needs a login and a password. Each user must belong to a primary group and haveaccess or other privilages to several other secondary groups.

    To create a new userlogin you need to be loged in as ROOT user.

    Command to create a new user “useradd“:



  • [-d] home directory
  • [-s] starting program (shell)
  • [-p] password
  • [-g] (primary group assigned to the users)
  • [-G] (Other groups the user belongs to)
  • [-m] (Create the user’s home directory)
  • Examples

    Now imagine you need to create a user called “JonDoe” with the password “lost” that has as primary group “MainGroup” and also he is assigned to “LostGroup” as well .

    – before this we need to make sure that the groups exist.

    Deleteing a User

    Command to delete a new user “userdel“:



    [-r] – remove the user directory content as well.

    Altering an User in Linux

    To alter a user specification we will use the “usermod” command.



  • [-d] home directory
  • [-s] starting program (shell)
  • [-p] password
  • [-g] (primary group assigned to the users)
  • [-G] (Other groups the user belongs to)
  • Example

    the most commond use of “usermod” command is the password change:

    – so we have just changed the password of JonDoe user.


    : we can also change the passowrd just using the “passwd” command. After creating a new user you need to give him a password, so for this you will need to use the “passwd” command:


    The “passwd” gives you the write to change your password by using the following Syntax

    If you are the root and decide to change the password of a user you will just use following Syntax :

    How to see the user information as “root” user.

    User names and primary groups are stored in


    .This file can be edited directly but is not recommended.

    To see the file just use the following command :


  • 1-User (name normally all lower case) -Should be between 1 and 32 characters in length.
  • 2-Password (encrypted – only contains the letter ‘x’) -Password is stored in /etc/shadow file
  • 3-User ID (a unique number of each user)Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for administrative and system accounts/groups.
  • 4-Primary Group ID -The primary group ID (stored in /etc/group file)
  • 5-Comment (Normally the person’s full name)
  • 6-Home directory (normally /home/

    – The absolute path to the directory the user will be in when they log in. If this directory does not exists then users directory becomes “/”.
  • 7-Default shell (normally /bin/bash) -The absolute path of a command or shell (/bin/bash).Typically, this is a shell.
  • To see the details for a specific user use this command

    su – Switch User command.

    To switch to another user, use the su command. This is most commonly used to switch to the root account.


    To switch to root account :


    To switch to another user :

    To return to original user, type exit and you will be back to previous user.

    List of commands that allow us to manipulate files

  • 1- cp
  • 2- mv
  • CP command

    -this command will be used to copy files and directories.



    For detailes about option for cp type this line at the bash line

    cp man


    cp info


    or by using the full path


    -Copies the contents of file1 into file2. If file2 does not exist, it is created;

    – otherwise, file2 is overwritten with the contents of file1.

    -Copy the contents of file1 (into a file named file1) inside of directory dir1.

    -Copy the contents of the directory dir1. If directory dir2 does not exist, it is created.

    – otherwise, it creates a directory named dir1 within directory dir2.

    MV command

    Renames a file or moves it from one directory to another directory.



    [-f] mv will move the file(s) without prompting even if it is writing over an existing target. Note that this is the default if the standard input is not a terminal.

    [-i] Prompts before overwriting another file.

    [oldname] The oldname of the file renaming.

    [newname] The newname of the file renaming.

    [filename] The name of the file you want to move directory – The directory of were you want the file to go.


    Moves the file myfile to the directory newdir.

    Moves (renames) the file ” file.txt” to wannabedba.txt.

    The files file1.txt, file2.txt, file3.txt are moved to directory directory1. Directory1 must exist or mv will exit with an error.

    Navigation inside Linux terminal.

    Since there are no file icons to click on, how do you find your files?

    Every file lives inside a directory. Directories can contain files, other directories,
    or any combination of the two.

    Windows navigation tree example:

  • -this is a basic structure of a windows OS:

    Linux navigation tree inside terminal:

    In this picture you will see all the principal directories.

    Here is a short description of the main directories content:

  • /root -This your main account directory. The root user (you) have this space to keep all your
    downloads, and anything else you want to keep in there basically.
    Don’t confuse the “root” directory with “root” meaning the super user. Two meanings for the same word.
  • /bin -This is where basic shell commands such as ls and mv reside. This directory is always
    in the executable path.
  • /boot -This is where the Kernel is stored and LILO gets its information from, and where module
    information is stored. your best bet is to ignore this directory completely as for a normal
    user, it is dangerous to play with
  • /dev -This is where your devices, or hardware is contained. Hardware devices can be accessed
    like files which is cool when you consider that you can echo a dial command to the modem
    on /dev/modem, and the modem will respond.
  • /etc -This is like the preferences folder on a Macintosh. Its a location where all programs
    create files that store their options. Here you can set up your preferences for an Internet
    connection, for QuakeII, for your eMail even.
  • /home -This is where your users have their accounts. If you have added any users other than
    your standard root account, they will show up here. It can also house the directories than
    your Web Server (Apache) accesses, if you have it installed.
  • /lib -This is where the basic libraries for booting Linux and running standard programs reside.
    Do not delete anything in this directory, ever.
  • /mnt -This is the location where you mount your cdrom, zip drives, or dos drives.
  • /opt -If you have this directory, its probably where Netscape has installed if you have chosen
    Netscape to be loaded. Red Hat’s Applix office suite also installs here.
  • /proc -Again, Im not too sure what lives in here. It seems to be an area where information is
    kept on your hardware devices and system board. Id advise against deleting anything in that directory.
  • /sbin -Rather like /bin really. The ‘s’ stands for System Binaries, where commands like shutdown
    lilo and fdisk are stored.
  • /tmp -A useless directory, its short for Temporary. When you install Linux first, it creates a file
    in your /tmp directory with all the details.
  • /usr -This is an interesting one. When you install programs like the GIMP, and Windowmaker,
    they need to be accessed by all users, so this is the directory they get installed into.
    Theres even another library directory for the new programs so that all users can see and access them.
    Basically, any program that is not automatically installed with the Distribution, and needs to be
    accessed by all users ends up in this directory
  • /var -This is where your log files, and printer files are kept. Its again something you shouldn’t need
    to know too much about.
  • To navigate or to see what is in the / “root” folder we will use the “list” command:

    We can see we get a list of all the above directories that reside int the ROOT “/” directory.

    Now let’s see what is in the HOME directory

    Always remember the slash before the name of the directory, otherwise you will
    get an error.

    Now in Linux we always have a “working directory” , even when we login we will be
    in our /home directory.

  • “working directory”= PWD(print working directory)
  • To find what is our actual “working directory” we will need to use the “PWD” command:

    Changing the working directory

  • to do so we will use the “CD”(change directory) command:
  • You can see our actual working directory before was our Home directory “home/wannabedba”
    and we have changed to “/home” by using the “cd” command.

    You can go up or you can go down the tree of directory’s using the “cd” command as long as you
    will provide the full path after the “cd” command:

    You can see that we are in the “/” root folder and we want to go to the “/etc/emacs” , just by using the
    “cd” command followed by the full path to the directory we want .
    If you want to go down one directory you can use the “cd ..” command:

    We can see that we went up one directory into our Documents and then we have moved down one dir back to our /home/wannabedba dir just by using the
    “cd ..” cd followed by a empty space and two points.

    To go up one dir you just use the “cd /(name of the directory)” command.

    File creation in Linux

    How do we create a file or a dir in Linux?

    There are several different commands that can be used to open, create, edit, or view a file in Linux.

    Create a new file

    VI command:

    -as default on most of the Linux OS we will have the “vi” command. “VI” command can be also used to edit already created files.

    How do we use the “vi” command to create a new file :


    -to create or edit a file:

    This is how a empty file looks like, you can edit this file by pressing the “i” key(insert).

    To save and exit the file :


    To exit the file without saving the the altered data :


    General Syntax used with “VI”:

    How to remove a file in Linux:

    Command :

    rm [option] “file name”


    [-f] -Forcefully remove file.

    Other Linux editos that can be used:


    -Allows you to look, modify or combine a file.


    [-n] -Precede each line output with its line number.

    [-b] -Number the lines, as -n, but omit the line numbers from blank lines.

    [-u] -The output is not buffered. (The default is buffered output.)

    [-s] -cat is silent about non-existent files.


    -Reads file1.txt and file2.txt and combines those files to make file3.txt.


    -Will show the last part of the file.


    To get more info about this command you can just open a bash and type :

    – this will pull out the manual for this command.

    There are many linux editors that are in use but we will only use the ones above.

    Now that we have learned how to create files let’s see how to create directory or folder.

    The command used for creating directory or folders is :

    -make directory.

    The general syntax is


  • [-m mode] Set permission mode (as in chmod), not rwxrwxrwx – umask.
  • [-v] Print a message for each created directory.
  • [-Z] (SELinux) set security context to CONTEXT.
  • [directory] The name of the directory that you wish to create.
  • To remove a dir just use the “rmdir” remove directory Command :



  • [-r], [-R] –recursive (remove directories and their contents recursively);
  • Note

    – if you try to delete the directory using rmdir command and you have some others files or other directorys you will get and error message.

    So in order for us to delete the dir and also what is inside of it we will use the “rmdir”

    option command “-r”:



    Very important :

    Never run (rm -rf / or rm -rf *)as an administrator or normal Linux user.this command will erase everything you have on your computer, and believe me Linux commands from the bash line are pretty quick, there is no way back from this(only a backup restore will save you).

    I will not demonstrate this command asi do not want my file system to go empty.

    What are permissions in Linux OS?

    Every file or folder in Linux has access permissions.This permissions will define what we can do with the files.

    There are three types of permissions:

  • read access
  • write access
  • execute access
  • Permissions are defined for three types of users:

  • the owner of the file
  • the group that the owner belongs to
  • other users
  • To see the permission of a file we can use the following command :

    will list all the objects in the current working directory

    We can see in the above image that we have 3 objects in our /Documents dir.

    File permissions notation

    Now let’s learn how to interpret all the crazy numbers and words and the other stuff on the terminal after the use the “ls -l” command.

    Since we are at the terminal line and we do not have any graphical and we can not click+right to see our file proprieties we need to learn how to interpret out terminal information.

    Textual representation

    Is represented by 10 characters.

    These permissions can be divided up as follows:

  • position 1 = type of object.(can be a file or a directory)(0———)
  • positions 2-4 = permissions for owner. (the user that created the file/dir)(-123——-)
  • positions 5-7 = permissions for group.(—-456—)
  • positions 8-10 = permissions for the rest of the users/visitors.(——-789)

  • Position 1 and it’s possible types:

  • d= directory .
  • -= file .
  • l= link to another file or object (like a Windows shortcut) .
  • s= socket .
  • == pipe .
  • b= block device (eg, a disk drive that handles data a block at a time) .
  • c= character device .

  • Positions 2, 3 and 4 tell us if the owner has read, write and execute permissions for the file or object.

  • 2 – r = read .
  • 3 – w = write (create, modify, delete) .
  • 4 – x = execute (run).
  • So if we have for example this situation :

    We can see in the above image that we have 3 objects in our /Documents dir.

    Let’s “translate” each of them :

  • we will start with the object/file called “dir1”
  • So how do we interpret this ?


    We can see the object is a Directory.


  • -the owner has the rights(


    ) – read,write and execute;
  • -the group has the rights(


    ) – read,has no rights to write and can execute;
  • -other visitors/users that are not the owner or they are not in the group have the rights (


    ) – read,has no rights ro write and can execute;
  • Links

    – we have 2 links to this dir.


    – the owner of this dir is “wannabedba”;


    – the group that “wannabedba” is part of is “wannabedba”;


    – the size of the file is 4.0 k or 4096 , if the dir has less then 4.0 k then it will show the minimum size of a block.(which is 4096);

    Data of creation/modified

    – we can see that this dir was created on 2012-03-29;

    Time of creation/modified

    – this dir was created/modified at 17:35;


    – the name of our dir is “dir1”;

    How to give and change permissions in Linux.

    For this task we will need to use the “Chmod” command.

    Syntax of the chmod command is:


  • [-R] set permissions recursively.

  • [-f] “forced” or silent mode.

  • [-v] “verbose”, show information for every file processed.

  • [-c] show information only if changes are made to the file.

    Numeric Permissions:

    CHMOD can be attributed by using Numeric Permissions:


    This gives the file read/write by the owner and only read by everyone else(-rw-r–r–).

    Here is shown how the octane and how they be used with “chmod”:

    First thing you need to know is that there are 10 bits associated with every file sliced in 4 parts (type,owner,group,guests) like we have learned at the begging of this tutorial.

    We will take an example of a file and show how permissions are represented in octal number, so we can apply them when we give permissions to our file,dirs.

    The existing permissions for the above file in octal numbers could be represented as follows

    Frequently used numeric parameters for chmod.

  • 755 -The general preferred permissions for almost all the files on your disk.
  • 700 -Extremely private data.
  • 500 -Extremely private data that you would not like to accidentally modify. So write protect it.
  • 775 -General files used when working as a Group (Others can only view/execute your files).
  • 770 -Important files used when working as a Group (Others cannot do anything with your files).
  • 750 -Allowing group to view your files but no write access (Others cannot do anything with your files).
  • 777 -Full permission for everybody (not very common).
  • In the next tutorial we will learn how to create new objects(files,dir,etc..) in Linux OS.

    Object Names in Linux

    File names can contain any characters other than forward slash ( / ),they are reserved for the “root dir”.

    File names use alphanumeric characters,underscores, hyphens
    and periods only. Other characters, such as dollar signs, percentage signs and brackets, have special meanings to the shell so we should avoid using them in out file names.File names should never begin with a

    Reserved characters and words

  • slash (/) -used as a path name component separator;
  • question mark (?) -used as a wildcard;
  • asterisk (*) -used as a wildcard;
  • greater than (>
    ) -used to redirect input;
  • less than (
    <) -used to redirect input;
  • While (?,*,
    ) – are reserved character they can be used in Linux file names(it is not recommended).
  • File names in Linux, are case sensitive. The file names “FILE” and “file” refer to different files.
  • File names can be as short as a single character or can go up to 255 bytes.
  • File names must be unique within a directory, but many files with the same name can reside in different dir.
  • Filename extensions

    Extensions are file name suffixes that start with a period.Linux can read many file extensions.Often, the directory where a file is placed is a better indication of what type of file it is.

    Linux has no concept of a “file extension” like legacy operating systems. You may name files any way you like.The contents/purpose of a file is determined by other means.But extensions are still used to identify the content.

    List of Linux file extension and the file type(content type):


    File Type
    .bz2 A file compressed using bzip2 .
    .c A file written in the C programming language.
    .conf A configuration file.
    .lock A



    that prevents the use of another file.
    .rpm A Red Hat package file….ing the alien utility .
    .so A shared object (a library or module).
    .src A source code file. Wri…be compiled to be used.
    .tar A single file made of a… using the tar command.
    .tar.gz A single file made of a…ressed used the


    .tgz A single file made of a… used the gzip command.
    .gz A file compressed using the gzip command.
    .txt a plain ASCII text file
    .ps a PostScript file; formatted for printing
    .au an audio file
    .wav an audio file
    .xpm an image file
    .jpg a graphical or image fi…h as a photo
    .gif a graphical or image file
    .pdf an electronic image of a document
    .a an archive file
    .h a C or C++ program language header file
    .cpp a C++ program language source code file
    .o a program object file
    .php a PHP Script
    .sh a


    .png a graphical or image file
    .tcl a TCL script
    .pl a


    .html/.htm an HTML file

    Basic commands:

    Here is a list of some common commands in Linux that we are going to use in the future tutorials.

  • ls -Displays a list of files in the current working directory, like the dir command in DOS.
  • cd -Change directories.
  • passwd -change the password for the current user.
  • file “filename” -display file type of file with name “filename” .
  • cat “textfile” -throws content of “text file” on the screen.
  • pwd -display present working directory.
  • exit or logout -leave this session.
  • man “command” -read man pages on “command”.
  • info “command” -read Info pages on “command”.
  • MS-DOS vs. Linux commands

    If you know MS-DOS terminal line commands then you can associate them with Linux commands.

    MS-DOS Linux / Unix


















    fdformat / mount / umount











    < file







    More about the above command in the following tutorials.Keep reading the tutorials and leave your comments and also share with your friends and not only with your friends

    Working with the Shell

    The shell is a program that will let you interact with the OS.We can also use the graphical user interfaces (GUI) to interact with the OS but in this tutorials we will just use the command line interfaces.On Ubuntu we have the bash that acts as the shell program.

    Let’s start the terminal:

    On Ubuntu the default shortcut keys to open the terminal are Ctrl+Alt+T.
    Or you can go to Application >> Accessories >> Terminal and click to open.

    Now after we have the terminal opened let’s see some basic futures of it: Start by typing something at the terminal line and press enter

    We can see that we got an error message, is telling us that he does not understand what we tell him.

    Example of the output:

    Now press arrow up …. and see that you can access the command history.This is a very useful thing for everyday stuff.

    You can even use the mouse inside the terminal. You can select, copy and paste as well.Using a 3 button mouse can make terminal work pretty easy because of scrolling ability.