Top Banner

of 22

Linux Commands for Newbies

Feb 11, 2018

Download

Documents

Genc Gashi
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/23/2019 Linux Commands for Newbies

    1/22

    Linux commands for new

    In the following slides you will learn several Lcommands which will be useful for somebody wjust starting with Linux.

  • 7/23/2019 Linux Commands for Newbies

    2/22

    Command: ls

    ls, stands for List Directory Content is a command to return a and directories residing within a directory. Default direct

    considers is the current directory.

    datasoft @ datasoft-linux ~$ lsabc1 pqr.txtabc1.txt psr1.shABC.png psr1.sh~abc.txt psr2.shajax-php-mysql-user-interface.html psr2.sh~...

  • 7/23/2019 Linux Commands for Newbies

    3/22

    Command: ls -l

    Adding a l option returns long listing. i.e. you can see permissigroup, date/time of creation of the file.

    datasoft @ datasoft-linux ~$ ls -ltotal 2324-rw-rw-r-- 1 datasoft datasoft 19 Aug 7 17:02 abc1-rw-rw-r-- 1 datasoft datasoft 19 Aug 7 17:02 abc1.txt-rw-rw-r-- 1 datasoft datasoft 0 Jul 29 13:39 ABC.png

    -rw------- 1 datasoft datasoft 107 Aug 2 16:07 abc.txt-rw------- 1 datasoft datasoft 1790 Sep 14 2013 ajax-php-mysql-uhtml...

  • 7/23/2019 Linux Commands for Newbies

    4/22

    Command: lsblk

    lsblk stands for List Block Devices. It prints block devices (exctheir assigned name on the standard output in a tree-like fash

    datasoft @ datasoft-linux ~$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 465.8G 0 disksda1 8:1 0 73.2G 0 partsda2 8:2 0 1K 0 part

    sda5 8:5 0 97.7G 0 partsda6 8:6 0 97.7G 0 partsda7 8:7 0 97.7G 0 partsda8 8:8 0 52.2G 0 partsda9 8:9 0 45.5G 0 part /sda10 8:10 0 1.9G 0 part [SWAP]

  • 7/23/2019 Linux Commands for Newbies

    5/22

    Command: lsblk - l

    Unlike lsblk, lsblk -l returns a list block devices in list structutree like structure.

    datasoft @ datasoft-linux ~$ lsblk -lNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 465.8G 0 disksda1 8:1 0 73.2G 0 partsda2 8:2 0 1K 0 part

    sda5 8:5 0 97.7G 0 partsda6 8:6 0 97.7G 0 partsda7 8:7 0 97.7G 0 partsda8 8:8 0 52.2G 0 partsda9 8:9 0 45.5G 0 part /sda10 8:10 0 1.9G 0 part [SWAP]

    datasoft @ datasoft-linux ~$

  • 7/23/2019 Linux Commands for Newbies

    6/22

    Command: md5sum

    The md5sum stands for Compute and Check MD5 Mesmd5sum is a computer program that calculates and verifieshashes. It is widely used to check whether file transdownloading) a file has been changed or not because of faulta disk error or non-malicious meddling

    datasoft @ datasoft-linux ~$ md5sum VNC-5.2.0-Windows.exe0eb0d0394663bbd940a2878c3468f599 VNC-5.2.0-Windows.exe

  • 7/23/2019 Linux Commands for Newbies

    7/22

  • 7/23/2019 Linux Commands for Newbies

    8/22

    Command: history

    The history command prints the history of long list of executein terminal.

    datasoft @ datasoft-linux ~$ history | more1024 cd datasoft 1025 ls1026 sort -k1 abc.txt1027 sort -k2 abc.txt

    1028 cat xyz.txt1029 sort xyz.txt1030 sort -k3 abc.txt1031 sort -n -k3 abc.txt1032 cat abc.txt1033 sort abc.txt

  • 7/23/2019 Linux Commands for Newbies

    9/22

    Command: sudo

    sudo refers to the file /etc/sudoers to determine who is an authowhile executing a command which requires a little more privileg

    current user has.

    datasoft @ datasoft-linux ~$ sudousage: sudo -h | -K | -k | -Vusage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user [command]usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] prompt] [-u user] [VAR=value] [-i|-s] []...

  • 7/23/2019 Linux Commands for Newbies

    10/22

    Command: mkdir

    The mkdir (Make directory) command creates a new directory wsupplied after the command mkdir. It returns cannot create foalready exists error if the the directory mentioned already exis

    datasoft @ datasoft-linux ~$ mkdir mydir

  • 7/23/2019 Linux Commands for Newbies

    11/22

    Command: touch

    The touch command stands for Update the access and mod

    of each FILE to the current time. the command creates the fexist, else it modifies the timestamp keep the contents of the f

    datasoft @ datasoft-linux ~$touch myfile

  • 7/23/2019 Linux Commands for Newbies

    12/22

    Command: chmod

    The Linux chmod command stands for change file mode bitschange the permission(s) of the file associated.

    datasoft @ datasoft-linux

    ~$ chmod 755 myfile

  • 7/23/2019 Linux Commands for Newbies

    13/22

    Command: chown

    The Linux chown command stands for change file owner and

    datasoft @ datasoft-linux~$ chown myfile user10chown: invalid user: myfiledatasoft @ datasoft-linux

    ~$ chown user10 myfilechown: changing ownershipof myfile: Operation notpermitted

  • 7/23/2019 Linux Commands for Newbies

    14/22

    Command: aptapt command stands for (Advanced Package Tool. Apt is package manager for Debian based system (Ubuntu, Kubunused to search, install, update and resolves dependency of

    Gnu/Linux System from command line.

    datasoft @ datasoft-linux ~$ sudo apt-get updateIgn http://security.ubuntu.com trusty-security InRelease

    Ign http://extras.ubuntu.com trusty InReleaseIgn http://in.archive.ubuntu.com trusty InReleaseGet:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]Hit http://extras.ubuntu.com trusty Release.gpgGet:2 http://security.ubuntu.com trusty-security Release [59.7 kB..

    ...

  • 7/23/2019 Linux Commands for Newbies

    15/22

    Command:tar

    The tar program is used to create, modify, and access files a

    tar format. "tar" stands for tape archive. It is an archiving file fo

    datasoft @ datasoft-linux~/dir2$ tar -cvf files.tarmyfile myfile2myfile

    myfile2datasoft @ datasoft-linux~/dir2$ lsfiles.tar myfile myfile2datasoft @ datasoft-linux~/dir2$

  • 7/23/2019 Linux Commands for Newbies

    16/22

    Command:cal

    The cal (Calendar), it is used to displays calendar of the preany other month of any year that is advancing or passed.

    datasoft @ datasoft-linux~/dir2$ cal

    August 2014Su Mo Tu We Th Fr Sa

    1 2

    3 4 5 6 7 8 910 11 12 13 14 15 1617 18 19 20 21 22 2324 25 26 27 28 29 3031

    C d d

  • 7/23/2019 Linux Commands for Newbies

    17/22

    Command:date

    The date (Date) command print the current date and time onoutput, and can further be set.

    datasoft @ datasoft-linux~/dir2$ dateWed Aug 20 12:52:54 IST2014

    C d t

  • 7/23/2019 Linux Commands for Newbies

    18/22

    Command:cat

    The cat stands for Concatenation. Though it is generally us

    contents of files from command line, it can also be used to copcombine text files and create new text files.

    datasoft @ datasoft-linux~$ cat myfilethis is file for demo

    C d

  • 7/23/2019 Linux Commands for Newbies

    19/22

    Command: cp

    cp stands for Copy. It copies a file from one location to anothe

    datasoft @ datasoft-linux~$ cp myfile dir2/

    C d

  • 7/23/2019 Linux Commands for Newbies

    20/22

    Command: mv

    mv command moves a file from one location to another locatio

    datasoft @ datasoft-linux ~$mv myfile dir2/

    C d d

  • 7/23/2019 Linux Commands for Newbies

    21/22

    Command: pwd

    pwd command is used to display the name of the current / predirectory.

    datasoft @ datasoft-linux ~$pwd/home/datasoft

    Command: cd

  • 7/23/2019 Linux Commands for Newbies

    22/22

    Command: cd

    Finally, the frequently used cd command stands for (changechange the working directory to execute, copy, move write, re

    terminal itself.datasoft @ datasoft-linux~$ cd dir2