Commands to view and edit files
View and edit Files | | cat | View filecontent Concatenate file from start to standard output (terminal screen by default). Usually takes filename as a parameter. cat > file (Enter text at command line and then CTRL-D to write to file.) | | grep | Search for a string from standard input or from a file. This is a powerful command. | | head | Show selected amount of lines from the start of a file. | | less | Display the contents of a specified file one screen at a time. Use the arrow keys to move up and down through the file.
less myfile Display the contents of the file myfile. | | more | Display the contents of a specified file one screen at a time. Use the spacebar to move forward through the file a screen at a time; use the Enter key to move forward through the file one line at a time.
more myfile Display the contents of the file myfile. | | more|less | These commands are almost the same, and usually act in a pipe. They are used for file pagination to terminal. Below are some example commands: zcat /var/log/vmksummary.1.gz | less more /etc/passwd | | nano | Edit a file with a bit easier UI that vi. nano -w /etc/fstab This is probably the very first file editing command you want/need. "-w" turns word-wrapping off, so you can more easily edit longer lines than about 74 characters. nano /etc/inittab nano /etc/bashrc | | tac | Like "cat", but starts from the end of the file (or standard input). | | tail | Like "head", but start from the end of the file. Practical command to follow what is happening with a log file is command like tail -f /var/log/messages. | | vi | Standard UNIX text editor
I ESC :wq (write and quit) :q! | |