Few basic useful linux commands for Developers

Posted By : Arvind Das | 03-Mar-2013

I have seen people struggling with the linux commands. When in need , they all start again googling it and will lose time after seeing a lot of options. Here are some mostly used commands that I believe will help you out in any situation.

 

Let us check it out first by looking at your Operating System.

1.) cat /etc/*release*

It will tell you your operating system name. Most of the time you will find a Red Hat/Amazon Linux/CentOs/Ubuntu/Debian releases. You can choose to run yum or apt-get commands accordingly.

2.) Which architecture am I using, 32 bit or 64 bit ?

uname -m

x86_64  means it is a 64 bit machine and i386/i586 are 32 bit machines.

3.) List all files and folders with their permissions.

ls -ltr

It will list all files and folders in the current directory with their permissions.

4.) I can not write into a file or my process can not write into that file. Change permissions of a folder or a file.

For file : sudo chmod 777 filename

For folder : sudo chmod -R 777 folder_name

Will open file or folder permissions for all.

5.) How can I connect to a machine launched in EC2 cloud or some other cloud ?

It depends on the security provided by these cloud hosting providers.

 i ) In case of amazon instances or others who provide security key file logins.First change permissions of file to 400.

sudo chmod 400 keyfile.pem

Now, connect to your instance :

ssh -i keyfile.pem user@server_ip

ii ) In case a keyfile is not provided and you have password :

ssh user@machine_public_ip

Choose yes for establishing connection and you are in.


 

6.) How do I download a file from a server or upload a file to it ?

Simply do sftp instead of ssh in the above command in point 5. Use get filename to download and put filename to upload the file to your servers. Files will be uploaded to your home direectory

7.) How to download a file to server ?

Simply use wget file_complete_url


 

8.) Nightmare, I have a source package .gzip formats. How do I install from a source ball . I have been using .deb or .rpm all the time. Now , how do I do it ?

Do not worry. Simply extract it to some location.

tar xvf file_name.tar.gz or unzip xvf file_name.zip

sudo ./configure

sudo make

sudo make install


 

8.) How to check all running  processes , cpu usage, load average , machine's ram and available system cores ?

Simply run top

             i.) press 1. It wil list number for cpu's available in your machine.

                Below, you fill find all running processes with their memory and processor usage.

             ii.) Use free -m

                 Will tell you available and free memory in Mb's.

9.) My process has hung up . How do I kill it ?

Run this command to find process id for your running process.

sudo ps -aef | grep pointing_name

Where pointing name is a name of type of a process or from which location it started. For example:

If I start a tomcat process , I can either use ps -aef | grep java or ps -aef | grep tomcat

Now , simply kill it

sudo kill -9 process_id

10.) I have a zipped installer. Where should I install it ?

You should install or your zipped installers to /opt and then set PATH for them.


 

I believe you will find above commands useful for you. I will keep updating them.

Cheers!

Thanks

Arvind Das

 

About Author

Author Image
Arvind Das

Technical Product Manager experienced in developing Real Time Planning Solutions, Video CMS with experience in Product Management and technical expertise in Reactive applications , Micro-services . Spending most of his time in planning , new solutions.

Request for Proposal

Name is required

Comment is required

Sending message..