Os Practical 1
Os Practical 1
Practical : 1
AIM : Study of Basic commands of Linux/UNIX.
Linux/UNIX
Linux is an operating system that was developed by Linus Torvalds in 1991. The name “Linux” originates
from the Linux kernel. It is an open-source software that is completely free to use. It is used for computer
hardware and software, game development, mainframes, etc. It can run various client programs.
Unix is a portable, multi-tasking, bug-fixing, multi-user operating system developed by AT&T. It started as
a one-man venture under the initiative of Ken Thompson of Bell Labs. It proceeded to turn out to become
the most widely used operating system. It is used in web servers, workstations, and PCs. Many business
applications are accessible on it.
Advantages of Linux:
1. Free & Open Source: It’s free to use, and anyone can change it.
2. Secure: Less likely to get viruses.
3. Stable & Reliable: It doesn’t crash easily and works well for a long time.
4. Customizable: You can change almost everything.
5. Good for Old Computers: It runs smoothly on older hardware.
6. Easy Software Updates: Linux makes installing and updating software easy.
7. Community Support: There’s a big community to help you out.
Disadvantages of Linux:
1. Not All Software Works: Some popular apps like Adobe Photoshop or Microsoft Office aren’t
available.
2. Hardware Issues: Some devices (like printers or Wi-Fi adapters) may not work right away.
3. Harder for Beginners: It’s not as easy for new users compared to Windows or macOS.
4. Not Great for Gaming: Fewer games and some might not work well.
5. Limited Commercial Software: Many paid software programs don’t have Linux versions.
230760107064 1
Subject Code: 3140702 Operating System
The pwd command is mostly used to print the current working directory on your terminal. It is also one of
the most commonly used commands.
-P :- The pwd command in Linux is used to display the current working directory, which is the directory
you are currently in.
-L :- Displays the logical current working directory, considering symbolic links.
Ls Command -List
The ls command is commonly used to identify the files and directories in the working directory. This
command is one of the many often-used Linux commands that you should know.
ls -l :- Use To show long listing information about the file/directory
ls -a :- List all files including hidden file starting with '.'
ls -r :- List in reverse order
ls -t :- Sort by time & date
230760107064 2
Subject Code: 3140702 Operating System
230760107064 3
Subject Code: 3140702 Operating System
Date Command
date command is used to display the system date and time. date command is also used to set date and time
of the system.
date +%A :- The full weekday name (e.g., Sunday)
date +%b :- The abbreviated month name (e.g., Jan)
date +%B :- Locale's full month name (e.g., January)
date +%C :- The current century; like %Y, except omit last two digit
date +%w :- day of week (0..6); 0 is Sunday
230760107064 4
Subject Code: 3140702 Operating System
Cat Command
The cat command is the simplest command to use when you want to see the contents of a particular file. The
only issue is that it simply unloads the entire file to your terminal.
cat -b :- Use Omits line numbers for blank space in the output
cat -E :- Displays a $ (dollar sign) at the end of each line
cat -n :- Line numbers for all the output lines
cat -s :- Suppress repeated empty output lines
cat -T :- Displays the tab characters as ^I in the output
230760107064 5
Subject Code: 3140702 Operating System
Who Command
The who command displays the following information for each user currently logged in to the system if
no option is provided.
-p :- Shows active processes spawned by init.
-q :- Displays only the logged-in users and their count.
-s :- Shows the default short who command output.
-t :- formats the display of output on the terminal screen.
whoami Command
The whoami command provides basic information that is extremely useful when working on multiple
systems. In general, if you are working with a single computer, you will not require it as frequently as a
network administrator.
whoami –help :- Use Display a help message, and exit
whoami --version :- Display version information, and exit
230760107064 6
Subject Code: 3140702 Operating System
Cp Command -Copy
The cp command of Linux is equivalent to copy-paste and cut-paste in Windows.
cp -I :- Use Interactive - ask before overwrite
cp -n :- Do not overwrite an existing file
cp -u :- Update - copy when source is newer than destination
cp -v :- Print informative messages
echo Command
echo command in Linux is specially used to print something in the terminal.
Mv Command -Move
The mv command is generally used for renaming the files in Linux.
mv -I :- Use Interactive prompt before overwrite
mv -f :- Force move by overwriting destination file without prompt
mv -n :- Never overwrite any existing file
mv -u :- Update - move when source is newer than destination
mv -v :- Print informative messages
230760107064 7
Subject Code: 3140702 Operating System
Rm Command -Remove
rm command in Linux is generally used to delete the files created in the directory.
Nl Command
nl command is a Unix/Linux utility that is used for numbering lines, accepting input either from a file or
from STDIN.
nl -I :- Use Line number increment at each line
nl -s :- Add STRING after (possible) line number
nl -w :- Use NUMBER columns for line numbers
230760107064 8
Subject Code: 3140702 Operating System
Ln Command
The ‘ln’ command in Linux is a powerful utility that allows you to create links between files. These links
can either be hard links or soft (symbolic) links.
-s, a stat call on a symbolic link returns the linked-to file;
-n, specifies that if the link is an existing file, do not overwrite the contents of the file.
ln -f :- Use If the destination file or files already exist, overwrite them
ln -i :- Prompt the user before overwriting destination files
ln -s :- Make symbolic links instead of hard links
Head Command
The head command, as the name implies, print the top N number of data of the given input. By default, it
prints the first 10 lines of the specified files.
head -n :- Use Print the first n lines instead of the first 10; with the leading '-',
print all but the last n lines of each file
head -c :- Print the first n bytes of each file; with a leading '-', print all but
the last n bytes of each file
head -q :- Never print headers identifying file names
Tail Command
The tail command, as the name implies, prints the last N number of data of the given input. By default, it
prints the last 10 lines of the specified files.
tail -n :- Use Output the last num lines, instead of the default (10)
tail -c :- Output the last num bytes of each file
tail -q :- Never output headers
230760107064 9
Subject Code: 3140702 Operating System
History Command
The history command is a valuable utility that allows users to view and search through their command
history. In this comprehensive guide, enabling users to streamline their workflow and save time by
efficiently accessing and reusing commands.
230760107064 10