1. Linux commands on the console may often span many lines, and encountering a type mistake at the beginning of the command would require you to use the slow way of punching the right/left arrow keys to traverse in the command string.
Remedy : Try Ctrl+e to move to the end of the command string and Ctrl+a to reach start. It’s the fastest way to edit a Linux command line. To delete a word in the command string, use Ctrl+w.
2. Another wonder of a simple shell variable is !$. Let’s say you have to create a directory, go into it and then rename it. So the flow of commands would be:
Code:
$ mkdir your_dir $ mv your_dir my_dir $ cd my_dir
Code:
$ mkdir your_dir $ mv !$ my_dir $ cd !$
!$ points to the last string in the command string.
3. Run the following code to get to know the basic block of any Linux command & what it does internally:
Code:
$ strace -c /usr/bin/ls
strace is a system call monitor command and provides information about system calls made by an application, including the call arguments and return value.
4. For creating a chain of directories and sub-directories, something like /tmp/our/your/mine?
Remedy: Try this:
Code:
$ mkdir -p /tmp/our/your/mine
5. One very interesting way to combine some related commands is with && or ; .
Code:
$ cd dir_name && ls -alr && cd ..
No comments:
Post a Comment