0% found this document useful (0 votes)
12 views

Practical 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Practical 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Department of : Subject of:

Computer Systems Engineering Operating System Design Concepts


Mehran University of Engineering & Year 3RD Semester 5TH
Technology
Batch F-16CS Duration 03
Hours
Jamshoro

Outlines
• Commands
− System Information
− File Commands
− Process Management
− Permissions
− Network
− Command Lists
− Sorting Files
• Shortcuts
− Nano Shortcuts
− Keyboard Shortcuts
• Exercise

Requirements
• Computer System with suitable Configuration
• Operating System Ubuntu 16.04.1

1
SYSTEM INFORMATION

date – Show the current date and time


cal – Show this month's calendar
uname – Show kernel information
cat > filename- creates file named ‘filename’
cat file1 file2- concatenates files and view the contents of file.
Sort filename- Sorting lines of text files in ascending order
df – Show disk usage
du – Show directory space usage free – Show memory and swap usage
man command- Show manual for command
passwd- changes your password

FILE COMMANDS

ls – Directory listing
ls -l – List files in current directory using long format
ls -laC – List all files in current directory in long format and display in columns
ls -F – List files in current directory and indicate the file type
ls -al – Formatted listing with hidden files
-a Show all (including hidden)
-R Recursive list
-r Reverse order
-t Sort by last modified
-S Sort by file size
-l Long listing format
-1 One file per line
-m Comma- separated output
-Q Quoted output
cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd(print working directory) – Show current directory
rm name – Removes or deletes a file or directory called name dir
rm-i- prompts for confirmation before deleting.
rm –r dir – Forcefully removes an entire directory and all its included files and
subdirectories (use with extreme caution).
cp file1 filedir – Copyfile1 to file dir .
mv file1 filedir – rename filedir with file1 name
file filename – tells you the type of file
more file – Display the file called file one page at a time, proceed to next page
using the spacebar.

2
head file – Output the first 10 lines of file.
head -20 file – Display the first 20 lines of the file called file.
tail file – Output the last 10 lines of file.
tail -20 file – Display the last 20 lines of the file called file.
tail -f file – Output the contents of file as it grows, starting with the last 10 lines.
wc- counts lines, words and characters
locate file – Find all instances of file.

PROCESS MANAGEMENT

ps (process status) – Display your currently active processes.


top – Display all running processes.
kill pid – Kill process id pid.
killallproc – Kill all processes named proc (use with extreme caution).
bg – Lists stopped or background jobs; resume a stopped job in the background.
fg – Brings the most recent job to foreground.
fg n – Brings job n to the foreground.

PERMISSIONS

chmod is used to change to change the permissions of files or directories.


On Linux, there is a set of rules for each file which defines who can access that
file. The command name chmod stands for "change mode", and it is used to
define the way a file can be accessed
chmod options permissions filename
permissions defines the permissions for the owner of the file (the "user"),
members of the group who owns the file (the "group"), and anyone else
("others").
1. the user can read, write, and execute it;
2. members of your group can read and execute it; and
3. others may only read it.
chmod 754 filename
Here the digits 7, 5, and 4 each individually represent the permissions for the
user, group, and others, in that order. Each digit is a combination of the numbers
4, 2, 1, and 0 (Octal number representation)
 4 stands for "read",
 2 stands for "write",

3
 1 stands for "execute", and
 0 stands for "no permission."

So 7 is the combination of permissions 4+2+1 (read, write, and execute), 5 is 4+0+1


(read, no write, and execute), and 4 is 4+0+0 (read, no write, and no execute).

chmod 777 filename – read, write, execute

for all. For more options, see man chmod.

NETWORK

Ifconfig (interface configuration) – View network configuration of network on


your system.
ping host – checks connectivity between two nodes.
whoisdomain – who own a domainname: info.
dig domain – Get DNS information for domain.

COMMAND LISTS
cmd1 ; cmd2- Run cmd1 then cmd2
cmd1 && cmd2- Run cmd2 if cmd1 is successful
cmd1 || cmd2- Run cmd2 if cmd1 is not successful

SORTING FILES

sort filenames
It sorts lines contained in a group of files alphabetically (or if the -n option is
specified) numerically. The sorted output is displayed on the screen, and may be
sorted in another file by redirecting the output. So

$ sort input1.txt input2.txt > output.txt - outputs the sorted concatenation


of files input1.txt and input2.txt to the file output.txt.

4
NANO SHORTCUTS
File
Ctrl-R
Read file
Ctrl-O
Save file
Ctrl-X
Close file

KEYBOARD SHORTCUTS
Enter – Run the command
Up Arrow – Show the previous command
Ctrl + R – Allows you to type a part of the command you're looking for and finds
it.
Ctrl + C – Halts the current command, cancel the current operation and/or start
with a fresh new line
Ctrl + L – Clear the screen
Ctrl + A – Return to the start of the command you're typing
Ctrl + E – Go to the end of the command you're typing
Ctrl + U – Cut everything before the cursor to a special clipboard, erases the
whole line
Ctrl + K – Cut everything after the cursor to a special clipboard
Ctrl + Y – Paste from the special
Ctrl + W – Delete the word / argument left of the cursor in the current line
Ctrl + D - Log out of current session, similar to exit.

5
EXERCISE
Q1: Describe in a few words what the following commands do and
show their outputs?

 Date
 Uname
 Pwd
 Ls
 Clear
 More

Q2: Name three text editors used in Linux

Q3: What is a GID?

Q4: How do you view access privileges for a file?

Q5: What is your home directory?

Q6: What hidden files are in your directory?

Q7: Create a file called myfile in your home directory.

Q8: How do you get a long listing of all of the files in your directory?

Q9: What command do you use to find out what group you belong to?

Q10: Explain how are read, write and execute file permissions are
controlled on file in a Linux file system.

Q11: What is meant when we say that a file is structureless in UNIX?

Q12: Explain what the following Linux commands do: chown, grep.

Q13: The output of the following command? $ whoami

Q14: What is the command used for getting the time at which the
System was last booted up

Q15: Write the command to list the contents of a folder according to

6
their size.

Q16: Write the command to find all the txt files in the current
directory.

Q17: Draw a Diagram to represent Directory Structure Of Linux OS


and explain the purpose of each directory.

Q18: Commands to display

 date and time in UTC


 date and time in RFC.

Q19: Command to display the calendar

 Current month
 Current year
 Year 2015

Q20: Explore at least 10 commands with their 5 options (each) and


show results.

You might also like