Basic Commands used for Operating Linux System as well as for Devops.

Basic Commands used for Operating Linux System as well as for Devops.

Indroduction

A quick introduction about Linux, it was developed by Linus Torvalds in 1991 based on Unix. Which is more easy to use and some other factors included. It is open source meaning source code is made public hence therefore it has may distributions such as AWS Linux, RedHat, Ubuntu, CentOS, etc. It has enhanced security, mainly used in servers, nearly 90% of internet runs on the linux. Linux Architecture includes Hardware, Kernel, Shell, Applications lastly Users.

Next about directory structure meaning the way files and folders are arranged in operating system the top most level is root(/) directory within this comes may other directories such as etc, tmp, mnt, lib, bin, sbin, root, home which have there own respective use.


Commands

There are many commands which are used, here are few of them to list

Here’s showing host name ~ symbol refers to present working directory. $ represents non-root user, # represents root user

ubuntu@ip-172-31-81-78:~$
  • pwd - tells about the present working directory.

  • ls - to list the files and directories of the present working directory.

    ls -i - listing based on inode values

    ls -r - listing in reverse order

    ls -t - listing based on time

    ls -a - listing the hidden files

    ls -s - listing based on the size

    ls -l - for long listing

  • cd- - change home directory

    cd .. - move to parent dir

    cd / - mover to root dir

    cd~ - move to current user dir

    cd- - move to previous dir

  • mkdir - to create a directory

  • touch - create a file

  • cp - copy the data

    cp -rf - copy data along with dir

  • rm - to remove or delete files

    rm -rf - remove data along with dir

  • mv - move or rename files

  • sudo su - - changing to root user

  • whoami - current user who is logged in

  • who - shows users who are logged in

  • file compression & extraction

    for compression: for extraction:

    tar -cf tar -czf

  • cat > filename - insert data in file (crtl+d) to exit after entering data

    cat filename - to display content

    cat filename > file2name - copy data form filename to file2name

    cat » filename - to append data to existing data

  • echo data > filename -insert data into file

    echo data » filename - append data to existing data

  • grep - search though files to find particular text string

  • clear - clear terminal display

Some of the commands for Devops learning

  • chmod - changing files permission

    read- 4

    write -2

    execute - 1

    no permission - 0 eg: chmod 421 filename

  • ps - displays information about process running in system showing the process id, status, & how may time it got executed

    ps -ef - list of all the process running in background

    top - real time monitoring of process

  • kill <pid> - to kill ps

    kill -9 <pid> - force fill

  • vim (vim editor) - vi file name press i for insert mode

    press esc after entering data

    :wq - write save and quit

    :w - write save and continue

    :q - quit

    q! - quit without writing and saving

    :wq! - write and quit forcefully