Linux for DevOps and Developers

Linux for DevOps and Developers

Complete Linux for developers and DevOps engineers

ยท

6 min read

History of Linux

In 1964, Bell laboratory started a project at New Jersey. Project was to create a multitasking and multiuser operating system And in 1969 they withdrawed that project. But Dennis Ritchie(developer of C language) and Ken Thompson did not give up on this project. This project was UNIX.

In 1969, Dennis Ritchie and Ken Thompson started on this project again. They made a OS called UNICS.(Uniplexed Information & computing services)

After sometime it called as UNIX. This was open source project.

In 1975, a new version of unix introduced- UNIX version 6. This was so popular at that time. So many companies made their versions using this open source unix operating system.

Examples:

Flavours of UNIX

  • IBM- AIX
  • SUN Solaris
  • Apple- MacOS
  • HP- UX
  • Linux
  • In 1991, There was a student Linus Torvalds. Linux began in 1991 as a personal project by Finnish student Linus Torvalds: to create a new free operating system kernel. The resulting Linux kernel has been marked by constant growth throughout its history. Since the initial release of its source code in 1991, it has grown from a small number of C files under a license prohibiting commercial distribution to the 4.15 version in 2018 with more than 23.3 million lines of source code,

    Linus Torvalds studies UNIX OS and MINIX(developer by Andrew Tenenbaum) and developed a kernel called LINUX.

    In between 1991 and 1995 there was a movement going on Free software movement- GNU.

    Linux is a kernel.

    As we know an OS is a mix of kernel and softwares. So OS was developed using linux kernel and GNU softwares.

    Many companies created their own version of OS using linux kernel.

    Examples:

  • RHEL(Red Hat Enterprise Linux)
  • Fedora
  • Debian
  • Others- Ubuntu, CentOS, Amazon Linux, Kali linux
  • Linux is a kernel not O.S Linux is not a Unix derivative, it was written from scrath. A linux distribution is the linux kernel and a collection of softwares that together create an OS.

    Linux features

  • Open Source
  • Secure
  • Simplified updates for all installed softwares
  • Light weight
  • Multiuser - multitask
  • Multiple distribution- Redhat, debian, fedora
  • File System Hierarchy

  • /
    Top level root directory
    • /root
      Home directory for root user.
    • /home
      Home directory for other users.
    • /boot
      Contains bootable files for linux. >POST: Power on Self Test
    • /etc
      Contains all configuration files.
    • /usr
      by default softwares are installed in this directory.
    • /bin
      (binary)Contains commands used by all users.
    • /sbin
      (system binary)Contains commands used by only root user.
    • /opt
      Optional application software packages.
    • /dev
      Essential device files, include terminal devices, usb or any deviice attached to the system.

    Linux basic commands

  • Creating a file in linux
    1. cat :- we can create or see the content but can't edit the file.
    2. touch :- create empty file,create multiple empty files.
    3. vi/vim :- it's an editor
    4. nano :- it's also an editor
    $ cat > file.txt
    >ctrl+d to exit
    
    $ touch file1.txt file2.txt file3
    $ vi files.txt
    $ nano file5.txt
    

  • Switch to root user
  • $ sudo su
    

    super user do switch user

  • cat Command
  • The cat command is one of the most universal tools, yet all it does is copy standard input to standard output.

    we can make use of cat command for following tasks:

    • create file- creating single file bash $ cat > file.txt # check content of file $ cat file.txt
    • Concatenate file- to add more than one file into a single file(We can't edit file but we can concatenate something in existing file) bash $ cat >> file.txt
    • Copy files- To copy the content of file1 into file2 bash $ cat file1 file2 > all.txt

  • Touch Command
    • Create an empty file bash $ touch file.txt
    • create multiple empty files bash $ touch file1 file2 file3
    • Change all timestamp of a file bash $ touch file.txt
    • Update only access time of a file, modify time of file bash $ touch -a file.txt #change access time $ touch -m file.txt #change modify time

    Time Stamp

    1. Access Time(last time when a file was accessed)
    2. Modify Time(last time when file was modified)
    3. Change Time(last time when file metadata was changed)

    How to check time stamp of file

    $ stat file.txt
    

  • Vi Editor
    • A programmer's text editor
    • It can be used to edit all kinds of plain text, it is specially useful for editing programs. Mainly used for unix programs. bash $ vi file.txt
      • :w -- To save
      • :wq or :x -- To save & quit
      • :q -- To quit
      • :q! -- force quit not save

  • Nano editor
  • $ nano file.txt
    

    For quit - ctrl+X

  • How to create a directory
  • $ mkdir dir1
    # Create directory inside a directory
    $ mkdir dir1/dir2/dir3
    

  • How to list files and directories
  • $ ls
    # also hidden files
    $ ls -a
    

  • Change Directory
  • $ cd dir1
    # go back parent dir
    $ cd ..
    

  • Check current directory
  • $ pwd
    # print working directory
    

  • How to Copy a file
  • $ cp file1 file2
    $ cp file.txt dir1/dir2/
    

  • How to cut and paste file
  • $ mv file dir1
    

  • How to rename a file
  • $ mv file1 file3
    

  • How to create hidden file or directory
  • $ mkdir .dir1
    $ touch .file.txt
    

  • How to remove file or directory
  • # remove file
    $ remove file.txt
    # remove the specified dir
    $ rmdir dir1
    # remove both parents and child dir
    $ rmdir -p
    # remove all the parents and subdirectories along with verbrox
    $ rmdir -pv
    # remove even non-empty file and directory
    $ rm -rf
    # Remove non-empty dir including parents and subdirectory
    $ rm -rp
    #  remove empty directories
    $ rm -r
    

  • Some other commands-
  • # to see head content of any file
    $ head file.txt
    # last content of file
    $ tail file.txt
    # more content
    $ more file.txt
    # Check history
    $ history
    

    Some advance commands

    • hostname
    • ifconfig, cat /etc/os-release
    • yum install httpd
    • yum remove httpd
    • yum update httpd
    • service httpd start
    • service httpd status
    • chkconfig httpd on
    • chkconfig httpd off
    • which
    • whoami
    • echo
    • yum list installed

  • hostname command
  • $ hostname
    

  • ifconfig, cat /etc/os-release
  • $ ifconfig # check ip address
    $ cat /etc/os-release # which os version
    

  • yum install httpd
  • yum is a package, yellowdog updatter modified used to install softwares or uninstall softwares or packages. httpd will install apache also

    $ yum install httpd
    

  • yum remove httpd
  • # remove package
    $ yum remove httpd
    

  • yum update httpd
  • # update package
    $ yum update httpd
    

  • service httpd start
  • $ service httpd start
    

  • service httpd status
  • $ service httpd status
    

  • chkconfig httpd on
  • # automatically start httpd when open computer
    $ chkconfig httpd on
    

  • chkconfig httpd off
  • $ chkconfig httpd off
    

  • which
  • # find location of package, installed or not
    $ which terraform
    

  • whoami
  • $ whoami
    

  • echo
  • # print on screen
    $ echo Hello
    

  • grep command
    • for finding specific content
    # find root in /etc/passwd directory
    grep root /etc/passwd
    

  • Sort command
    • sort file content or data in alphabetical sorting format
    sort filename.txt
    

    Did you find this article valuable?

    Support KubeKode Blogs by becoming a sponsor. Any amount is appreciated!

    ย