• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Linux Basics

    I would like to give a brief intro for all the basic commands which will be required for all the new comers in Linux., I will continue this article with more commands in another page.

    Basic Linux Commands

    # tty Shows the current logged in terminal
    # whoami shows the currently logged in user
    # which "command name" reveals where in the search path a program is located
    # echo prints to the screen
    # echo $PATH dumps the current path to STDOUT
    # echo $PWD     dumps ths contents of the $PWD variable
    # echo $OLDPWD dumps the most recently visited directory
    # clear         clears the screen or terminal
    # reset         resets the screen buffer
    # history       reveals your command history
    # !110 executes the 110th command in our history 

    Files and Directories

    # ls             list the files and directories in the present working directories
    # ls -ltr        sort the files in the last modification time in reverse order
    # ls -a          list all the files including hidden files and directories ( all files starting with "." are hidden files)
    # ls -l          long list of all files and directories where you can check the relative permission on each file.

    # mkdir "directory name"                 Create directory
    # mkdir -p /"dir1"/"dir2"/"dir3"/        Create directory including parent dir
    # touch "filename"                       Create files

    # cp "dir1"  /root/    copy directory or file to another location
    # mv dir1  /root/      move or rename the dir or file to different location

    # rm "dir name"        To remove directory
    # rm -rf "dir name"    To remove a directory recursively and forcefully

    For further switches to be used with any of the above commands you can check using
    # man "command name"
    # "command name" --help

    For example:
    # rm --help
    # mkdir --help
    # ls --help

    # cd            with no options changes to the $HOME directory
    # cd ~          changes to the $HOME directory
    # cd /          changes to the root of the file system
    # cd Desktop/   changes us to the relative directory 'Desktop'
    # cd ..         changes us one-level up in the directory tree
    # cd ../..      changes us two-levels up in the directory tree

    User and Group related

    # useradd "username"                      creates a user
    # passwd "username"                       Assign password to user
    # groupadd "groupname"                    creates a group
    # usermod -a -G "groupname" "username"    Add existing user to group
    # groupmod -A username groupname          Add existing user to group

    # useradd -d "directory name" -s "shell" -g "group name" -u "UID" "username"                                 Creates user with provided details

    Command chain

    # head /var/log/messages      displays opening lines of text files
    # head -10 /var/log/messages  displays opening 10 lines of text files
    # tail /var/log/messages      displays the closing lines of text files
    # tail -10 /var/log/messages  displays the closing 10 lines of text files
    # wc -l /var/log/messages     counts words and optionally lines of text files
    Linux Basics Linux Basics Reviewed by admin on Friday, November 23, 2018 Rating: 5


    1. # rm "dir name" To remove directory
      instead of above use "rmdir directoryname"

      1. rmdir will only work if the directory is empty, so first the directory has to be cleaned up

    2. Thanks for sharing these commands.


    Powered by Blogger.