collegeCurriculum

Bash Commands

  1. Create the following directory structure
    flowchart TD
     A[nirmala] --> B[ug]
     A --> C[pg]
     B --> D[ba]
     B --> E[bsc]
     B --> F[bcom]
     B --> G[bca]
     C --> H[ma]
     C --> I[msc]
     C --> J[mcom]
     C --> K[mca]
    
    mkdir -p nirmala/{ug/{ba,bsc,bcom,bca},pg/{ma,msc,mcom,mca}} #you could also expand it
    
  2. Remove the directory bcom
    rmdir nirmala/ug/bcom
    
  3. Change to parent directory
    cd ..
    
  4. Display the contents of current directory in detail
    ls -al 
    
  5. Display the current path
    pwd 
    
  6. Change the name of bca to nbca
    mv nirmala/ug/bca nirmala/ug/nbca
    
  1. Change to nbca
    cd nirmala/ug/nbca
    
  2. Create file bcastudent
    cat > bcastudents #a blank cursor will appear, and type what you want to store, Ctrl+c to exit and save
    
  3. Sort the names in bcastudents
    sort bcastudents 
    
  4. Create a file in mca directory and after that display the sorted content
    cd ../../pg/mca 
    cat > mcastudents
    sort mcastudents
    
  5. Append into bcastudents
    cd ../../ug/nbca
    cat >> bcastudents #append to the file
    cat bcastudents #print the whole file
    
  6. Search for a particular data in bcastudents
    grep "keyword" bcastudents
    
  7. Display all files including hidden
    ls -a
    
  8. Count the number of lines in bcastudents
    wc -l bcastudents
    
  9. Translate the lowercase letters into uppercase letters in bcastudents
    cat bcastudents | tr "[a-z]" "[A-Z]"
    
  10. Implement pr command
    pr bcastudents
    
  11. Create files f1, f2, f3, f4 in nbca
    cat >> f1
    cat >> f2
    cat >> f3
    cat >> f4
    
  12. Implement find command
    find -name f1 -print
    
  13. Delete file f4
    rm f4
    
  14. Create a file f5 and implement cut command
    cat >> f5
    cut -c 1,2 f5
    
  15. Implement head and tail
    head -2 bcastudents
    tail -2 bcastudents
    
  16. Implement file command
    file *
    
  17. File comparison
    cmp f1 f2
    diff f1 f2
    
  18. Implement chmod command
    chmod 777 f5
    

Mathematical Commands

  1. Workout various mathematical commands
    bc #ctrl+d to exit
    expr 2 + 5 #space is needed between operands and operator
    factor 49
    

Miscellaneous Commands

  1. Implement the working of ls command
    cd ..
    touch f1 f2
    ls
    ls f*
    ls f?
    ls b*
    
  2. Implement various system related commands
    uname
    who
    who am i
    hostname
    
  3. Get the shell details
    echo $0
    cat /etc/shells
    echo $PATH
    
  4. Get terminal name
    tty
    
  5. Get primary prompt
    echo $PS1
    
  6. Get secondary prompt
    echo $PS2
    

Date Command

  1. Implement cal command
    cal
    
  2. Display current time and date
    date
    
  3. Get current date
    date "+%D"
    
  4. Get current day
    date "+%A"
    
  5. Get current month
    date "+%h"
    
  6. Get last 2 digits of current year
    date "+%y"
    
  7. Get current year
    date "+%Y"
    
  8. Get current time
    date "+%T"
    
  9. Get current hour
    date "+%H"
    
  10. Get current minute
    date "+%M"
    
  11. Get current second
    date "+%S"
    
df
du

PS Command

  1. Get the details of processes
    ps
    

TEE command

  1. Redirect the output of a process into another file
    ls -l | tee f1
    

Other Commands

  1. Get the login name of the user
    logname
    
  2. Redirect error into a file
    las -l 2> f5
    cat f5
    

VI EDITOR

  1. Create a file f1 and save content into it and quit
    vi f1
    :wq
    
  2. Open the same file and copy the first line and paste it into third line
    vi f1
    :1co3
    
  3. Delete the second and third line
    :2,3d
    
  4. Delete a word from current position
    dw
    
  5. Save and Exit from the file
    :wq