Reading files and terminal comfort: cat, less, tail -f, alias
Sign in to read this lesson
Reading configuration files and watching logs live are among an admin's most frequent tasks. In this lesson we learn to pick the right tool for the file size (cat, less, head, tail), follow a log with tail -f, use the command history and create our own shortcuts with alias.
What you will learn
catshows a small file at once; for a big file useless— page by page, with search (/word, quit withq).head -n 20shows the start of a file,tail -n 20the end; the last lines of a log are usually the most important.tail -ffollows a file live: new lines appear as they are written. Stop it with Ctrl+C.historylists the commands you typed;!!repeats the last command (e.g.sudo !!), Ctrl+R searches the history.alias ll='ls -alF'creates a shortcut; to keep it, put it in~/.bashrc.
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.