LINUX COMMANDS ALL IN ONE

 In this article, You can learn Linux commands. You can learn ls, cat, mv, sudo, rm, mkdir, rmdir, man, history, and clear commands.

 To open the terminal, press Ctrl+Alt+T in Ubuntu, press Alt+T in Parrot OS or press Alt+F2, type in gnome-terminal, and press enter. In Raspberry Pi, type in lxterminal. There is also a GUI way of taking it, but this is better!

 

 LINUX COMMANDS

> Copy and Paste in Terminal

Press " CTRL + SHIFT + C " for copy in Terminal.  

Press " CTRL + SHIFT + V " for paste in Terminal. 

There are several options for copy and pasting like Edit -> Copy, Paste. 

 

> The Ls command 

    ls 

Displays files in the current directory. Directories are shown in blue color and files are shown as white color.

    ls </path>

Displays files in the given path.

    ls -R

Listing Sub directories / Files. Use capital letter 'R'.

    ls -al

Getting detailed file information.

First column shows File types & Access permissions, second column shows Memory blocks, third column shows owner of file, fourth column shows size in bytes, fifth column shows Date & Time, and sixth column shows Directory Names. 

    ls -a

Viewing hidden files. Hidden files start with '.' period symbol. 

> The CAT command

It is used for creating & viewing files.

    cat > filename 

Enter some text values and press ctrl + d.

    cat filename

It shows file contents in Terminal

    cat filename_1 filename_2 > newfile

It concatenate two files into a new file called "newfile". After complition it does not show any confirmation message.

 

> The Rm command

    rm <filename>

This command is used for deleting files. After completion it does not show any confirmation message.

    rmdir <directoryName>

This command is used for deleting directories. Remeber that, Deleting sub-directories and files under the directory first.

 

> The Mv command

    mv <FileName> <NewFileLocation> 

To move file from current location to another location, this command is used. For running this command you have to enter as Super User mode.

    mv <FileName> <NewFileName>

To rename a file you can use this command. This command requires two values i.e. file name and new file name.

    mv <DirectoryName> <NewDirectoryName>

To rename a directory you can use this command. This command requires two values i.e. directory name and new directory name.

 

> The Sudo command

    sudo mv <FileName> <NewFileLocation> 

To move file from current location to another location, sudo command with mv command is used. After that, file name and file location is placed. This commands requires superuser password. This password still present in Terminal for 15 mins.

    sudo !! 

It re-runs the previous command.

 
> The Mkdir command
 
    mkdir <directoryName>

This command is used for creating directories. 

    mkdir </path/new_directory_name> 

This command is used for creating directory at a new location.

    mkdir <dir1> <dir2> <dir3>

This command is used for creating multiple directories.

 

> The Man Command

Man stands for manual. The reference book for linux system. It is simple to Help file.

     man <command> 

This command used for getting all information of a command which is given.

 

> The History Command

    history

Shows commands have used in the past.

 

> The clear command

    clear

Clear the screen.

 

> The ifconfig command

    ifconfig

Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.
 If no arguments are given, ifconfig displays the  status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down. Otherwise, it configures an interface.

 
> The Ping command
 
    ping <ipaddress>
 
Ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway. ECHO_REQUEST datagrams (“pings”) have an IP and ICMP header, followed by a struct timeval and then an arbitrary number of “pad” bytes used to fill out the packet.

ping works with both IPv4 and IPv6. Using only one of them explicitly can be enforced by specifying -4 or -6.

ping can also send IPv6 Node Information Queries (RFC4620). Intermediate hops may not be allowed, because IPv6 source routing was deprecated (RFC5095).


> The Update & Upgrade Command
     
    sudo apt-get update
    sudo apt-get upgrade

This command is used for update and upgrade.

> The uname command
 
    uname
 
uname is a command-line utility that prints basic information about the operating system name and system hardware.
 
    uname -r 
    uname -a
For more details you can use it.

 

> The Cd command

The cd (“change directory”) command is used to change the current working directory in Linux and other Unix-like operating systems. 

When specifying a directory to change to, you can use either absolute or relative path names. The absolute or full path starts from the system root /, and relative path starts from your current directory.

    cd <DirectoryName>

You can navigate to it by using the relative path to the directory.

You can also navigate to the same directory by using its absolute path:

    cd </path/directoryName>

In short, if the path starts with a slash (/) it is the absolute path to the directory.

    cd ..

To switch the previous directory, from current directory. Suppose you are currently in the /usr/local/share directory, to switch to the /usr/local directory (one level up from the current directory), you would type "cd ..". To move two level up to the /usr directory, you could run the following: "cd ../../".

 


 

 

 

Comments

Popular posts from this blog

IMPORTANT INTERVIEW RELATED QUESTION

C++ Interview Questions

SUBLIME TEXT CHEAT SHEET