Each program has a set of file descriptors. It’s like an open stream from / to file. On start program has 3 descriptors: standard input (stdin), standard output (stdout) and standard error (stderr). They has numbers: from 0 to 2. Standard input is used for reading input data from the user (from the terminal). StandardContinue Reading
Month: January 2019
How to get top 10 largest files
As we already saw, we can easily get to 10 largest directories (see “How to get top 10 largest directories in the current directory“). But there we used du utility – it shows directory size (or “estimate file space usage”). What utility shows file size? Oh… It’s just the ls! Looks easy? But we needContinue Reading
How to make an immutable file
As we already know, files have access right matrix (read more in this article: “File and directory permissions in Linux / FreeBSD / MasOS“). But that’s not all. There are more mechanisms for accessing files. For example, we can change file’s attributes. One of them is immutability attribute. Users with high capabilities can set /Continue Reading
Three useful keys of tail util
tail – output the last part of files. Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input. Tail’s keys Show last ‘num’ lines in file: tail -n {{num}}Continue Reading
How to get top 10 largest directories in the current directory
Sometimes it’s not obvious, which directory is too big. To find the biggest directories in you computer, you may use graphic user interface and some of supported file managers. But what will you do when you don’t have a GUI? And it’s not mythical situation. On the desktop you almost always know the biggest directoryContinue Reading
Useful keyboard shortcuts in Bash for beginners
Hotkeys in Bash helps you use Bash more efficiency. Most of them have slower analogs. But some of them help you easier do common things. Ctrl + a – Return to the start of the command you’re typing Ctrl + e – Go to the end of the command you’re typing Ctrl + u – Cut everything beforeContinue Reading
Bash history util for beginners
history is a program for tracking terminal input. Many programs read input from the user a line at a time. The GNU History library is able to keep track of those lines. It associates arbitrary data with each line, and utilize information from previous lines in composing new ones. Tips and examples Display the commandsContinue Reading
How to fix the last command in Bash
Sometimes we all makes mistakes. And it’s good if this is just typo in command name and we don’t erase important data. So, if it was just a typo Bash gives to us easy way to fix it! Takes the last command, replaces string1 with string2 and executes it. ^string1^string2 For example: $ ehco fooContinue Reading
How to get top 10 commands
It’s more like a joke / just for jun task. But it also perfectly shows one of the Unix principle: Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new “features”. Actually even two principles; Write programs to handle text streams, because thatContinue Reading
How to copy from a terminal to the Linux or MacOS system clipboard
When you use a clipboard of your desktop environment (DE), you may think, that it’s some global buffer. But it’s not it works inside DE. For example, come terminal utils use their own buffers – vim has its own buffers for working inside the editor. But we have commands which you can use to copyContinue Reading