Some Crazy Linux Commands

Some Crazy Linux Commands

 1. If we type mistake at the beginning of the command in terminal would require you to use the slow way of punching the right/left arrow keys to travel in the command string.

 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.

some Crazy Linux Commands


2. Another wonder of a simple shell variable is !$.

$ mkdir raj
$ mv raj raj2
$ cd raj2

3. Well, Linux has a shorter and quicker way.

$ mkdir raj
$ mv !$ raj2
$ cd !$

=> here we can use ALT + . or ESC + . Or !$
=> ALT + . and ESC + . print the previous argument
=> !$ points to the last string in the command string

4. What if you want to create a chain of directories and sub-directories, something like /tmp/our/your/mine?

 $ mkdir -p /tmp/our/your/mine

P – parent directory

5. One very interesting way to combine some related commands is with &&.

$ cd dir_name && ls -alr && cd ..

6. Have you ever tried checking the vulnerability of your Linux system? Try a fork-bomb to evaluate this:

$ : (){ : |: & };:

It’s actually a shell function; look closely and it’s an unnamed function : () with the body enclosed in {}. The statement ‘:|:’ makes a call to the function itself and pipes the output to another function call—thus we are calling the function twice. & puts all processes in the background and hence you can’t kill any process. Finally ‘;’ completes the function definition and the last ‘:’ initiates a call to this unnamed function. So it recursively creates processes and eventually your system will hang. This is one of the most dangerous Linux commands and may cause your computer to crash!

 How to avoid a fork bomb? Of course, by limiting the process limit; you need to edit /etc/security/limits.conf. Edit the variable nproc to user_name hard nproc 100. You require root privileges to modify this file.

7. One more dirty way to hack into the system is through continuous reboots, resulting in the total breakdown of a Linux machine. Here’s an option that you need root access for. Edit the file /etc/inittab and modify the line id:5:initdefault: to id:6:initdefault:. That’s all! Linux specifies various user modes and 6 is intended for reboot. Hence, your machine keeps on rebooting every time it checks for the default user mode.
check – Modify your Grub configuration (the Linux bootloader) and boot in single user mode. Edit the file /etc/inittab and change the default user level to 5.

One thought on “Some Crazy Linux Commands

Leave a Reply

Your email address will not be published. Required fields are marked *