Module 4
Module 4
Module 4
Linux Fundamentals
Commands Syntax
• Command options and arguments
Options:
Modify the way that a command works
Usually consist of a hyphen or dash followed by a single letter
Some commands accept multiple options which can usually be grouped together after a single hyphen
Arguments:
Most commands are used together with one or more arguments
Some commands assume a default argument if none is supplied
Arguments are optional for some commands and required by others
File Permissions
• UNIX is a multi-user system. Every file and directory in your account can be protected
from or made accessible to other users by changing its access permissions. Every user has
responsibility for controlling access to their files.
-r--r--r--
Permission Using Numeric Mode
• The table below assigns numbers to permissions types
• whatis command
• command –-help
• man command
TAB Completion and Up Arrow
• Hitting TAB key completes the available commands, files
or directories
• chm TAB
• ls j<TAB>
• cd Des<TAB>
• Output (stdout) - 1
• By default when running a command its output goes to the terminal
• The output of a command can be routed to a file using > symbol
• E.g. ls -l > listings
pwd > findpath
• If using the same file for additional output or to append to the same file then use >>
• E.g. ls –la >> listings
echo “Hello World” >> findpath.
• Error (stderr) - 2
• When a command is executed we use a keyboard and that is also considered (stdin -0)
• That command output goes on the monitor and that output is (stdout – 1)
• If the command produced any error on the screen then it is considered (stderr – 2)
• We can use redirects to route errors from the screen
• E.g ls –l /root 2> errorfile
telnet localhost 2> errorfile.
The symbol for a pipe is the vertical bar ( | ). The command syntax is:
ls -l | more
File Maintenance Commands
• cp
• rm
• mv
• mkdir
• rmdir or rm -r
• chgrp
• chown
File Display Commands
• cat
• more
• less
• head
• tail
Filters / Text Processors Commands
• cut
• awk
• grep and egrep
• sort
• uniq
• wc
cut - Text Processors Commands
cut
• cut is a command line utility that allows you to cut parts of lines from specified files or piped data and
print the result to standard output. It can be used to cut parts of a line by delimiter, byte position, and
character
• What is grep?
• The grep command which stands for “global regular expression print,” processes text line by line
and prints any lines which match a specified pattern
• What is wc command?
• The command reads either standard input or a list of files and generates: newline count, word
count, and byte count
• tar
• gzip
• gzip –d OR gunzip
Truncate File Size (truncate)
• The Linux truncate command is often
used to shrink or extend the size of a file to
the specified size
• Command
• truncate –s 10 filename
Split file.txt into 300 lines per file and output to childfileaa,
childfileab and childfileac