Friday, 7 December 2012

Linux Terminal Hacks


Linux Terminal Hacks

This command will be very useful when you are running programs which tend to drag on the system resources. Open terminal and type:
$ ps aux c
It will show you a complete list of running processes. The first column contain the user owner of the process, the second one is the PID of the process and if we jump to the last column we will see the name of the application which belong to each processes. If the application you want to kill is, for example, Firefox, then it would be:
$ ps aux c | grep firefox and then write kill -9. The next time you do a ps aux c | grep firefox, this program shouldn’t appear anymore.

Tracing Symbol Links

Here is an easy way to trace the endpoint of a cascaded symbolic link- for example: /dev/cdrom:
$ namei /dev/cdrom
f: /dev/cdrom
d /
d dev
l cdrom -> sr0
b sro
…….where, f:is the path name we are trying currently to resolve, d means directory, l means symbolic link and b means a block device.check man namei for more details.

Get the basic system information

There are some commands you can use to determine basic information of your machine such as kernel version, hardware information and others. The following command lines shows what they’ll return when executed;
$ cat /proc/version
It returns a full string of information about your Installed Linux
$ uname -m
“The result of the machine’s number”
$ uname -r
“Show the version of the kernel”
$ uname -n
“Returns the local domain name”
$ uname -s
“Will show the system name”
$ uname -p
“It tells you the type and name of the processor”
$ uname -a
“Will show all the information above and also the date and time of the system

Disk Space

Having sufficient and optimized disc space is something vital for good performance of your system. In the case of Linux, here are the different ways to optimize your storage space and display information of your hard disc.
$ df -h
“This command display the free disc space”
$ fdisk -l
“Very similar to Windows environment show you the partitions of the disc”
$ ls -lSr
“Display the all the files and the biggest last”
$ du -s * | sort -k1,1rn | head = “Show top disc users in the current directory”

Making Backups

Firstly make a directory by using following command
$ mkdir abc
Now to make backup, type following command
$ tar -cvf xyz.tar abc
Here xyz is another file where backup is taken.
Now to recover data type following command.

Frozen Windows

Sometimes you can have a frozen window, and there are two fast ways to solve this problem without turning off your computer or restarting it. First, you can try the traditional key combination of Ctrl + Alt + Backspace.
The other way is a little more complicated than the previous one but is more efficient. Hit Ctrl + Alt + F2 to jump to the virtual console. Then log in with your user name, password and type the following:
$ ps -ax | grep startx
This executed command will provide you the PID of your Xserver. Then kill it with the next command
kill -9 PID_Number
If you want return to your first console, just press Alt + F1.

Searching of Files

Faster method to search for almost anything under a Linux platform.
find -name ‘*.[ch]‘ | xargs grep -E ‘expr’ “Search ‘expr’ in the current directory and below”
find -type f ! -perm -444 = “Find files not readable by all”
locate -r ‘file[^/]*\.txt’ = “Search cached index for names”

No comments:

Post a Comment

Note: Post Your Comments With Your Name Thanks!
Kindly Share this post with your friends. Please don't forget to leave your review about any game you are going to download. Leave a comment if you find any dead link i will update the post within 1-2 days.
Thanks You!

LinkWithin

Related Posts Plugin for WordPress, Blogger...

web news