Head
Head
basic
commands
Check File/Folder/Content
LS TAIL
LL LESS
CAT MORE
GREP - ECHO
HEAD
LS
ls command
The ls command is the basic command used to list
files and directories within the Linux and other
Unix-based of the current directory by default.
ls
you will not be able to see file types, dates, and
permissions.
ls options ls --help
ls -l
ls path
ls -1
LL
Linux ll is not a command provided by the linux
system. It is usually the command alias we set.
Generally, the ls -l command is set to ll.
seshadri@seshadri:~$ which ll
seshadri@seshadri:~$ which ls
/usr/bin/ls
seshadri@seshadri:~$ type ll
ll is aliased to `ls -alF'
seshadri@seshadri:~$ type ls
ls is aliased to `ls --color=auto'
CAT
The cat (short for “concatenate“) command is one
of the most frequently used commands in
Linux/Unix-like operating systems. It is also
command utility in Linux. One of its most common
usages is to print the content of a file onto the
standard output stream. Other than that, the cat
command also allows us to write some texts into
a file.
cat [OPTION] [FILE]
# cat /etc/passwd
Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the
filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the
pattern
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular
expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line,
with each such part on a separate output line.
-A n : Prints searched line and nlines after the result.
-B n : Prints searched line and n line before the
result.
-C n : Prints searched line and n lines after before
the result.
For instance, to search for a filename that contains a
string “test“, the command would be
$ ls -l | grep -i “string”
$ ls –l | grep –i test
This command lists all the files that contain the string
“test”.
2. -v, –verbose: Always display the header name when file is identified.
4. -c, –bytes=[-]num: Displays the first num bytes of each file; with a
leading ‘-‘, displays all but the last num bytes of each file.
5. -q, –quiet, –silent: It restricts the printing of header name when file
identified.
$ head -n 5 asian_countries.txt
$ tail -f logfile
$ tail –help
less /etc/updatedb.conf
less -N /etc/init/mysql.conf
It will show output along with line numbers
dmesg | less -N
To view the output of another command with less, redirect the
output from that command using a pipe
Options Function
more -num Limits the line displayed per page.
more -d Displays user message at right corner.
more -s Squeeze blank lines.
more +/string name It helps to find the string.
more +num Used to display the content from a
specific line.
While viewing the text file use these
controls
$ echo *$
$ echo -e 'Hello, \vWorld, \vthis \vis \vPNAP!'
$ echo *.txt
$ cat hello.txt