Linux handy commands


As you use Linux more and more as with any operating system you meet challenges and need to find the solutions. Linux has a raft of commands, Many build into the core system. These commands will be used over and over again. Some will be second nature as you use them all of the time others you will use perhaps once a year.

One of the difficulties that you will find though is matching the command to what you want to do, I have created this post therefore to highlight the commands but to also put them into context in real life problems and issues, it also a good aide memoire for me ūüôā

Contents of this as hopefully it will get long:

How to find the PID of a process / How to find the PID of a process based on the port number being used.

Set server to a specific time zone

How to find the PID of a process / How to find the PID of a process based on the port number being used.

I was playing with an FTP server in Amazon EC2 more about this when I have figured it out!!! and needed to end the FTP process, there is no service yet so I needed to kill the process and needed to understand how to get the PID to kill it so:

lsof -i | grep <port number> / process name

e.g.

lsof -i | grep ftp

NOTE sometime the port number is of no use

You  will get a result something like this :

vsftpd   19744     root    3u  IPv4  24265      0t0  TCP *:ftp (LISTEN)

The PID in this instance is 19744

Just use the standard kill command in Linux to stop the process

kill -9 19744

Set server to a specific time zone

I need to set my Amazon server to UK BST time, There are no servers in the UK so the time is incorrect, to rectify this.

To display the timezones available

ls /usr/share/zoneinfo/

cd /etc

ln -sf /usr/share/zoneinfo/GB localtime

GB appears to be BST, to check the date and time

date

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s