This tutorial shall help anyone to score 25 marks in the IIT Madras System Commands OPPE exam.
Here are the 10 commands that you can learn to score 25 marks: pwd, ls, cd, mkdir, chmod, chown, touch, ln, man, and rm. We'll explore their usage, options, and real-world applications to help you learn:
The man
command is your go-to resource for understanding all other Linux commands. It's indispensable for exam preparation and on-the-spot information retrieval. Remember that you can always use man
command and help
command during the exam in the vm.
man [section] command_name
-f
: Display a short description from the manual page-k
: Search the short descriptions for keywords$ man ls
# This opens the manual page for the ls command
$ man -k directory
mkdir (1) - make directories
rmdir (1) - remove empty directories
# ... (more results)
Exam Tip: Practice navigating man pages efficiently. Knowing how to quickly look up command options can save you time during the exam.
The pwd
command helps you identify your current location in the filesystem.
pwd
-L
: Print the logical working directory (default)-P
: Print the physical directory, without resolving symbolic links$ pwd
/home/user/documents
$ cd /var/www/html
$ pwd
/var/www/html
$ pwd -P # Useful when working with symlinks
/var/www/html
Exam Tip: Be prepared to use pwd
in scenarios involving directory navigation and symbolic links.
The ls
command displays directory contents and file information.
ls [options] [directory]
-l
: Long format, showing detailed information-a
: Show all files, including hidden ones-h
: Human-readable file sizes-R
: Recursive listing$ ls -lah
total 32K
drwxr-xr-x 4 user user 4.0K Aug 24 10:00 .
drwxr-xr-x 3 user user 4.0K Aug 24 09:55 ..
-rw-r--r-- 1 user user 18K Aug 24 09:58 document.txt
drwxr-xr-x 2 user user 4.0K Aug 24 09:59 project1
drwxr-xr-x 2 user user 4.0K Aug 24 10:00 project2
Exam Tip: Practice combining options like ls -lah
for comprehensive file listings, as exams often require interpreting detailed file information.
The cd
command is used for navigating the filesystem.
cd [directory]
cd ..
: Move to parent directorycd ~
or cd
: Move to home directorycd -
: Move to previous directory$ pwd
/home/user
$ cd documents/projects
$ pwd
/home/user/documents/projects
$ cd ../..
$ pwd
/home/user
$ cd -
$ pwd
/home/user/documents/projects
Exam Tip: Practice navigating quickly between system directories and your home directory, as this is often part of multi-step exam questions.
The mkdir
command creates new directories.
mkdir [options] directory_name
-p
: Create parent directories as needed-v
: Print a message for each created directory$ mkdir -p projects/{web,mobile}/{src,tests,docs}
$ tree projects
projects
├── mobile
│ ├── docs
│ ├── src
│ └── tests
└── web
├── docs
├── src
└── tests
8 directories, 0 files
Exam Tip: Master the use of -p
for creating nested directories, as this can save time in complex directory creation scenarios.
The chmod
command changes file permissions.
chmod [options] mode file
$ ls -l script.sh
-rw-r--r-- 1 user user 234 Aug 24 09:57 script.sh
$ chmod 755 script.sh
$ ls -l script.sh
-rwxr-xr-x 1 user user 234 Aug 24 09:57 script.sh
Exam Tip: Practice both numeric (755) and symbolic (u+x) modes for changing permissions, as exams may require you to use both formats.
The chown
command changes file ownership.
chown [options] user[:group] file
-R
: Change ownership recursively$ ls -l data.txt
-rw-r--r-- 1 user user 1234 Aug 24 10:10 data.txt
$ sudo chown root:admin data.txt
$ ls -l data.txt
-rw-r--r-- 1 root admin 1234 Aug 24 10:10 data.txt
Exam Tip: Understand the implications of changing ownership, especially in scenarios involving system files or multi-user environments.
The touch
command creates empty files or updates file timestamps.
touch [options] file_name
-c
: Do not create any files-t
: Use specific time instead of current time$ touch newfile.txt
$ ls -l newfile.txt
-rw-r--r-- 1 user user 0 Aug 24 10:15 newfile.txt
$ touch -t 202108241020.00 oldfile.txt
$ ls -l oldfile.txt
-rw-r--r-- 1 user user 0 Aug 24 10:20 oldfile.txt
Exam Tip: Be prepared to use touch
for creating placeholder files or updating file timestamps, which might be part of scripting or file management questions.
The ln
command creates links between files.
ln [options] target link_name
-s
: Create a symbolic (soft) link-f
: Force creation of link, overwriting existing destination file-r
: Create relative symbolic links$ echo "Original content" > original_file
$ ln original_file hardlink
$ ln -s original_file symlink
$ ls -li original_file hardlink symlink
1234567 -rw-r--r-- 2 user user 17 Aug 24 10:30 hardlink
1234567 -rw-r--r-- 2 user user 17 Aug 24 10:30 original_file
1234568 lrwxrwxrwx 1 user user 13 Aug 24 10:30 symlink -> original_file
Exam Tip: Understand the differences between hard and symbolic links, as exam questions may test your knowledge on their behavior and use cases.
The rm
command removes files and directories. Use with caution!
rm [options] file
-r
: Remove directories and their contents recursively-f
: Force removal without prompting-i
: Prompt before every removal$ ls
file1.txt file2.txt olddir
$ rm file1.txt
$ rm -r olddir
$ ls
file2.txt
Exam Tip: Be cautious with rm -rf
in exams. Understand its power and when it's appropriate to use.