Linux Commands and Tips

1. For removing any folder from current directory and its sub-directory:

Run following command to see all existing folder:

find . -name folder_name -exec ls {} \;

Now run following command to remove all, after running following command you can run above command again for varification

find . -name folder_name -exec rm -rf {} \;

2. For removing any file from current directory and its sub-directories:

rm -rf 'find ./ type d -name '

3. Generate a new SSH key

ssh-keygen -t rsa -C ""

4. download file or folder from remote server:
At your local machine’s terminal,
For file run following:

scp [username]@[remote_ip]:[file_name] [destination_folder]

And For Folder run following:

scp -r [username]@[remote_ip]:[folder_name] [destination_folder]

4. Find out Linux Distribution Name and Version

Here are two simple ways to find out it:
a. using release file:

cat /etc/*-release

b. lsb_release:

lsb_release -a

5. Add to remote server:

 cat ~/.ssh/

Copy you pub key and run(assuming you have pem file of your server)

ssh -i [file_name].pem ubuntu@[IP]
vi ~/.ssh/authorized_keys

It will open a file and now you just need to past your pub key at the end of this file.
Now you can login without using ‘.pem’ file.


One thought on “Linux Commands and Tips

Leave a Reply

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

You are commenting using your 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