Transcript
  • 8/19/2019 Marking Guide for Linux EXCERCISE

    1/3

    Page 1 of 3 

    Linux Practice Exercise 1 

    1.  Go to your home directory and create the following directories as shownin the directory structure given below. 

    mkdir VCcd VCmkdir DVCcd DVCmkdir Deans Registrar

    mkdir -p VC/DVCcd VCcd DVCmkdir Deans Registrar

    mkdir -p VC/DVCcd VC/DVCmkdir Deans Registrar 

    mkdir -p VC/DVC/Deanscd VC/DVCmkdir Registrar

    Create the following files in the VC directory (use the touch command tocreate empty files)

    i. 

    Deans.docii.

     

    Registrar.txtiii.

     

    HR.xls 

    cd ..touch Deans.doctouch Registrar.txttouch HR.xls 

    2. 

    Write down the path to the Deans directory /home/username/Desktop/VC/DVC/Deans 

    3.  What commands would you issue to: a)

     

    Copy the file Deans.doc to the Deans directory. cp ~/Desktop/VC/Deans.doc ~/Desktop/VC/DVC/Deans

    the ~ just means that some preceding directories in the path not shown.The full path would be /home/yourusername/Desktop/VC/DVC/Deans

    cp Deans.doc ~/Desktop/VC/DVC/Deans orcp Deans.doc /home/yourusername/Desktop/VC/DVC/Deansare also ok as I am more interested in the command used and seeingwhere you are copying the file.

    b) 

    Rename the file copied to the Deans directory and call it Deans2.doc 

  • 8/19/2019 Marking Guide for Linux EXCERCISE

    2/3

    Page 2 of 3 

    mv Deans.doc Deans2.docc)

     

    Copy all remaining files to the Registrar directory cp ~/Desktop/VC/*.* ~/Desktop/VC/DVC/Registrar

    d)  See all files in the Registrar directory ls 

    e) 

    Remove the directory DVC. rm -R DVC 

    f)  Move the file HR.xls to the Deans directory mv ~/Desktop/VC/DVC/ Registrar /hr.xls ~/Desktop/VC/DVC/ Deans

    g) 

    Delete the file registrar.txt rm Registrar.txt

    h)  Look for the file lecturers.pdf in your home directory find -name “lecturers.pdf” (-name is used to remove case sensitivityin case you are not sure of the case, otherwise, you can use find“lecturers.pdf”)

    i) 

    Search for the text “computational” in the files of your home directory.grep -i “computational” *

    j) 

    Shutdown your computersudo shutdown -h now

    k)  Restart your computersudo shutdown -r now

    l) 

    Shutdown at 11:00am with the message “Systems will be shut down formaintenance at 8:00pm and will be restored at 12:00am”sudo shutdown -h 11:00 “System is going down for maintenance thisevening at 18:30 p.m. Please make sure you have saved your workand logged out by then or you may lose data.”

    m) 

    Clear the screenclear 

    n)  Close the terminal exit 

    4. 

    Briefly state the purpose of each of these commands in linux? o)

     

    ls –l gives you details about a file. Details like permissions, the ownerof the file, when it was created, its size, links if any, etc (Lists files in“long” format)

    p) 

    sudo –i Enables you to continuously work as the super user q)

     

    grep searches all files in the current directory for a string/text youwant to search for and prints matching lines along with the name ofthe file

    r) 

    who shows you who is loged in, what terminal, when and at whattime 

    s) 

    cd used to return to your home directory but if used with adirectory name, it used to change to that directory

    t) 

    cd ~ return to home directory u)

     

    touch used to create an empty file v)

     

    vi Linux text editor, just like nano and emacs w)

     

    at used to execute commands at a specified time x)

     

    ps provides information about processes, including their PIDs.

  • 8/19/2019 Marking Guide for Linux EXCERCISE

    3/3

    Page 3 of 3 

    5.  Write down the linux commands used to: 

    a) 

    Create a user called Anna sudo useradd Anna 

    b)  Assign a password to Anna (make her password coolA!) sudo passwd

    Anna

    c) 

    Change Anna’s password from “coolA!” to “;ladynna7 sudo chpasswd

    Anna[Leave out the other processes that prompt a user to enter the new

    password. The above line is enough]

    d)  Create a group called Clients sudo groupadd Clients 

    e) 

    Make Anna a member of the group Clients useradd -G Clients Anna 

    f) 

    Delete user Anna sudo userdel Anna 

    g) 

    Delete the client group sudo groupdel Clients 

    6.  Interpret the line below: 

    a) 

    drwxr-xr-x 2 becky class 4096 2015-01-16 17:07 Documents

    this is a directory, denoted by the “d” that precedes the file

    permissions

    the owner of the file can read write and execute

    the group to which the owner belongs can read, cannot write but can

    execute

    others can read, cannot write but can execute

    the owner of the file is becky who belongs to the group called class

    the file size is 4096

    it was created on 2015-01-16 at 17:07and the file is called Documents

    (Remember that in Linux, everything is called a file. In this case, this

    file is a directory. A file can be a directory, an ordinary file, devices

    or links)

    b) 

    Change the permissions in question 6 a) above to enable other system

    users to only read, group to only execute and the owner to have read 

    and write permissions on Documents. Use both the numeric codes and

    mnemonic notations to achieve this.

    i.  Mnemonic Notationchmod u-x Documentschmod g-r Documentschmod o-x Documents

    ii.  Numeric Notationchmod 614 Documents


Top Related