Practical 3
Practical 3
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
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
PERMISSIONS
3
1 stands for "execute", and
0 stands for "no permission."
NETWORK
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
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
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.
Q12: Explain what the following Linux commands do: chown, grep.
Q14: What is the command used for getting the time at which the
System was last booted up
6
their size.
Q16: Write the command to find all the txt files in the current
directory.
Current month
Current year
Year 2015