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

Linux Questions

# ls lists files and folders in the current directory. # ls -l shows a long listing format with details like file permissions and sizes. # ls -a lists all files including hidden ones. # cat displays the contents of files. # head and # tail can be used to view the beginning or end of files. # wc counts lines, words, and characters in files. Redirecting output with > or >> allows sending command output to files.

Uploaded by

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

Linux Questions

# ls lists files and folders in the current directory. # ls -l shows a long listing format with details like file permissions and sizes. # ls -a lists all files including hidden ones. # cat displays the contents of files. # head and # tail can be used to view the beginning or end of files. # wc counts lines, words, and characters in files. Redirecting output with > or >> allows sending command output to files.

Uploaded by

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

Questions Command

Listing all files and folder presents in current folder # ls


Listing all files and folder in reverse order # ls –r
Listing all files and folder in Long Listing Format # ls –l
Listing last modified files and folder # ls –t
Listing hidden files and Folders # ls –a
Listing hidden files and folders excepts .(Dot) Folders # ls –A
Listing data by their type # ls –F
Listing files and folders with disabling the colors # ls –f
Listing files and folders with their respective inode number # ls –i
Listing files and folder in Recursive format # ls –R
Listing the files and folder with their respective size # ls –s
Listing files and folders in human readable form # ls –h
Listing all files and folders with disable color and by file type # ls –fF
Read content of file using cat command # cat 0< filename
Read content of file with line numbers # cat –n filename
Read content of file and skip the blank line number to print # cat –b filename
Read content of multiple files simultaneously # cat file1 file2
Create a new file with some content (Save : CTRL + D) # cat > filename
Append some extra data to an existing file # cat >> filename
Copy content of one file to another # cat file1 > file2
Append content of one file to another # cat file1 >> file2
Copy of content of multiple files to a single file # cat File1 File2 > file3
View content of file in vertical Reverse order # tac filename
View content of file in horizontal Reverse order # rev filename
View First 10 Lines of the file # head –n 10 filename
# head -10 filename
View content of file except last 10 lines # head –n -10 filename
View n numbers of characters of a file # head –c n filename
View n numbers of characters except last n number of characters # head –c –n filename
View Last 10 Lines of the file # tail –n 10 filename
# tail -10 filename
View Last n number of characters of the file # tail –c n filename
View content of file in range of lines [a-b] # head –b filename | tail b-a+1
From 3rd to 7th Line # head -7 filename | tail -5
From 45th to 90th Line # head -90 filename | tail -46
From 15th to 23rd Line # head -23 filename | tail -9

Count Number of Lines in a file # wc –l filename


Count Number of Characters in a file # wc –c filename
Count Number of Words in a file # wc –w filename
Count Number of Lines, words, Characters in a file # wc filename
Count Number of Lines and Words in file # wc –lw filename
Count Number of Lines and Characters in a file # wc –lc filename
Count Number of Words and Characters in a file # wc –wc filename
Print Number of characters present in longest line # wc –L filename

Redirect the output of ls command to a file # ls > filename


Redirect the output of cal command to an existing file # cal >> filename
Write to a file using cat command and redirection # cat > filename
Append to a file using cat command and redirection # cat >> filename
Show standard output for ls command to a file # ls 1> filename
Show standard output for ls command to a file as appending # ls 1>> filename
Redirect standard errors to a file not to terminal # cal linux 2> error
Redirect standard errors to an existing file # cal linux 2>> error
Redirect standard input from terminal to a file # cat 0< filename
Redirect standard input and standard output from/to a file # cat 0< input 1> output
Read input from a.txt and write output to b.txt, and if error comes then write to c.txt # cat 0< a.txt 1> b.txt 2> c.txt
Redirect standard output and error to a common file # cat a.txt 1> o.txt 2> o.txt
# cat a.txt &> o.txt
Append standard output and error to a common file # cat a.txt &>> o.txt
How to see current Terminal Number or TTY # tty
Redirect standard output from one terminal to another terminal # ls 1> /dev/pts/1

You might also like