Search This Blog

Sunday, September 18, 2011

Trips_Tricks

harddrive measure
- The speed of the hard drive can be measured using the "hdparm" command:
   $ hdparm -t /dev/harddrive

top command
- The CPU load can be measured using the "top" command.

Share your directory
-  To share your directory with others on you network, serve current directory tree at,
"http://$HOSTNAME:8080"

# twistd -n web --path /home/share/folder

After running this on yur computer, type "http://HOSTNAME/IPAddress:8080"  in browser on any
machine within your network.

Removing special characters from text files created in Windows
-  Sometimes, when you open a text file in Linux that was originally created in Windows, special charaters like '^M' appears here and there.
To remove them,
# vim text.txt

Hit 'Esc' and type:

:set ff=unix

Now, save the file

:wq

Thats it.

Splitting a large file into multiple small files
-  We can use the "Split" command to break a large file into multiple smaller files.

#split --bytes=1024m --suffix-length=1 -d rhel.iso cd-


The above command will break the file "rhel.iso" into multiple files of 1024 MB with names 'cd-1', 'cd-2', and so on.

If you do not provide option '-d', it will instead use an alphabetic suffix while naming the files.  In this case, file names will appear as 'cd-a', 'cd-b' and so on.


Hide your commnds from your terminal's history
-  Give a blank-space between prompt and command as below:

$  ping google.com

Now, if you type history, you can not find ping command in your history.  This is because of a blank-space between $ and command.

The power of "Yes" command
Assume you have to create a large file or fill a whole disk to test the 'disk quota'.  Linux has a pwerfull command known as "Yes" to do such tasks.

It generates a string repeatedly until the command is killed.

#yes > /path/to/file/yes_test_file

This will type the string 'y' in the directed file "yes_test_file"

#yes lfy > /root/Desktop/yes_test

This will type the string "lfy" in the directed file "yes_test"




No comments:

Post a Comment