Skip to main content

Crazy Commands


Many of us who love to work on Linux enjoy the privilege of using a plethora of commands and tools. Here is our effort to introduce you to a few very simple- to-use, yet enormously effective commands. The intended audience may belong to all classes of Linux users and the only requirement is to have a basic acquaintance with Linux. Our article deals with bash shell and Linux version Fedora 9, kernel 2.6.25.
  1. Often, commands on the console may 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:
    $ mkdir your_dir
    $ mv your_dir my_dir
    $ cd my_dir

    Remedy: Well, Linux has a shorter and quicker way:
    $ mkdir your_dir
    $ mv !$ my_dir
    $ cd !$

    !$ points to the last string in the command string. This is useful in various scenarios where the last word of command string is to be used in subsequent commands (almost with all Linux commands like vi, tar, gzip, etc).
  3. Do you want to know what an ls or a datecommand does internally? Just run the following code to get to know the basic block of any Linux command:
    $ 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. What if you want to create a chain of directories and sub-directories, something like /tmp/our/your/mine?

    Remedy:Try this:
    $ mkdir -p /tmp/our/your/mine
  5. One very interesting way to combine some related commands is with &&.
    $ cd dir_name && ls -alr && cd ..
  6. Now for some fun! 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!

    Remedy: 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.

    Remedy: 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.
I hope you’ll have some fun trying out these commands, and that they bring you closer to Linux. Please do share your feedback and comments.


This Post has been taken from :
http://www.linuxforu.com/teach-me/tips-tricks/crazy-commands/?phpMyAdmin=1d8b5f958924edce27dfa99df2ab8e99

Comments

Popular posts from this blog

CentOS / Redhat : Configure CentOS as a Software Router with two interfaces

Linux can be easily configured to share an internet connection using iptables. All you need to have is, two network interface cards as follows: a) Your internal (LAN) network connected via eth0 with static ip address 192.168.0.1 b) Your external WAN) network is connected via eth1 with static ip address 10.10.10.1  ( public IP provided by ISP ) Please note that interface eth1 may have public IP address or IP assigned by ISP. eth1 may be connected to a dedicated DSL / ADSL / WAN / Cable router: Step # 1: Enable Packet Forwarding Login as the root user. Open /etc/sysctl.conf file # vi /etc/sysctl.conf Add the following line to enable packet forwarding for IPv4: net.ipv4.conf.default.forwarding=1 Save and close the file. Restart networking: # service network restart Step # 2: Enable IP masquerading In Linux networking, Network Address Translation (NAT) or Network Masquerading (IP Masquerading) is a technique of transceivin

Virtual Box and Alt/Tab Keys

I use virtual box for all my testing activities. It comes too often that I have a virtual box VM window open & I want to switch to my host machine to see some stuff like tutorials etc.. If you press the alt+tab combination it just works inside the VM & doesn't switches to host machine. In these scenarios you can press the host key once ( not hold it ) & then whatever you press goes to host machine. So in general where host key is the default Right Ctrl, just press Right Ctrl once & now press the alt+tab & it will switch you out to host machine. This is really helpful when you have the VM windows open or you're working on seamless mode. Hope it help others too.

AMD Radeon™ HD 7670M on Ubuntu 12.04

Update:   Recently I install kubuntu 13.10 and there is no problem with graphics. It just works  fine out of the box. I've seen many blog posts on how to make AMD HD7670M work on Ubuntu 12.04, specially when its in switchable graphics board like Dell Inspiron 15R 5520. I tried many things to make it work so that I could use the cinnamon desktop on ubuntu & other things too.. But to my surprise even the drivers from AMD site didn't work. Then I tried a combination of those blog posts I read & somehow I became successful in running the full graphics including compiz settings inside My Ubuntu Machine. Following are the steps I followed & it worked... 1. Create a backup of your xorg configuration file: sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK 2. Remove/purge current fglrx and fglrx-amdcccle : sudo apt-get remove --purge fglrx* 3. Install the driver: sudo apt-get install fglrx fglrx-amdcccle 4. Install additional