Linux Tips & Tricks

  1.  Hiding of commands

Some time we want to hide what we typing on terminal in Linux because of various reason like someone watching our command prompt & we want not to copy our commands or many times used in scripts as well like in writing the passwords.

For this we can use stty -echo, with this we type is not visible on CLI screen but output is visible to everyone. So in this manner what we are typing is not visible to anyone but the result of the same is visible on terminal.
When we need to make it normal or visible inputs on terminals again use “ssty echo”

2 .  No USB will attach

Some time for security reasons, we want that nobody able to attach USB drives on Linux systems.
For this we need to open system’s /etc/grub.conf file in editor 7 edit it in manner that show below

kernel /vmlinuz-2.6.18-128.el5 ro root=LABEL=/ rhgb quiet nousb

   After this our system will not support any USB drives.

[root@srv30 ~]# cat /etc/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:  You have a /boot partition.  This means that

#          all kernel and initrd paths are relative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00

#          initrd /initrd-version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title Red Hat Enterprise Linux Server (2.6.18-128.el5)

root (hd0,0)

kernel /vmlinuz-2.6.18-128.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet nousb

initrd /initrd-2.6.18-128.el5.img

3. How to know our current shell

    Some time we need to know our current shell, this can be done with this

    echo $0

4. How to know current Users

There are various ways to know the current user in like whoami. But most of time in case of scripting we use echo $USER, this is most safest & coolest way to the current user

5. Linux Multiple ping

You used Multi-ping for montring many times from Windows system, Linux also have this kind of utility for command promt.
fping is used as multiping witn command promt of Linux system..

root@lappy:~# fping 10.71.15.171 10.71.15.172 10.71.15.173
10.71.15.171 is alive
10.71.15.172 is alive
10.71.15.173 is alive
root@lappy:~# fping -l 10.71.15.171 10.71.15.172 10.71.15.173
10.71.15.171 : [0], 96 bytes, 205 ms (205 avg, 0% loss)
10.71.15.172 : [0], 96 bytes, 198 ms (198 avg, 0% loss)
10.71.15.173 : [0], 96 bytes, 202 ms (202 avg, 0% loss)
10.71.15.171 : [1], 96 bytes, 198 ms (201 avg, 0% loss)
10.71.15.172 : [1], 96 bytes, 197 ms (198 avg, 0% loss)
10.71.15.173 : [1], 96 bytes, 199 ms (201 avg, 0% loss)

6. LINUX Listing today’s files only
ls -l –time-style=+%D | grep `date +%D`

7.LINUX Methods to Identify Your Linux File System Type (Ext2 or Ext3 or Ext4)

1.mount | grep “^/dev”
2. file -sL /dev/sda1
3. cat /etc/fstab
4. fsck -N /dev/sda1

8. LINUX How to Tell 32 or 64-bit?
getconf LONG_BIT

9. LINUX How Do You Find The Number of CPU Cores
cat /proc/cpuinfo | egrep “physical\ id|core\ id”
physical id : 0
core id : 1
cpu cores : 2
If you have two CPUs in cpuinfo with the same physical id and core id, than – hyperthreading! When you have all CPUs with different physical ids, than you have SMP, and when you have CPUs with one physical id and different core ids – you have one multicore CPU. And so on…