1. ls -alF
The ls command is used to list files and directories in Linux. The options -alF modify the behavior of ls:
-a: List all files, including hidden files. Files that start with a dot (.) are hidden in Linux, and this option ensures they are included in the listing.-l: Use the long listing format, which provides detailed information about each file, such as:- Permissions
- Number of links
- Owner
- Group
- File size
- Last modified time
- File or directory name
-F: Appends a character to the end of each file name to indicate its type:/for directories*for executable files@for symbolic links|for FIFOs (named pipes)
So, ls -alF will list all files (including hidden) in long format and indicate the types of files with specific symbols.
2. cat
The cat command is used to display the entire contents of a file in the terminal. For example, if you have a text file called file.txt, you can run:
cat file.txtThis will show the entire contents of the file in the terminal. It’s helpful for viewing small to medium-sized files directly.
3. head
The head command is used to view the first few lines of a file. By default, it shows the first 10 lines. For example:
head file.txtThis command will show the first 10 lines of file.txt. If you want to specify how many lines to display, you can use the -n option. For example, to view the first 20 lines:
head -n 20 file.txt4. tail
The tail command is used to view the last few lines of a file. By default, it shows the last 10 lines. For example:
tail file.txtThis will display the last 10 lines of file.txt. Like head, you can also specify the number of lines to show using the -n option. For example, to view the last 20 lines:
tail -n 20 file.txtAdditionally, tail has a useful option for monitoring files in real-time (for example, log files) using the -f option:
tail -f file.txtThis will keep the terminal open and display new lines as they are added to the file, useful for watching log updates in real-time.