Some Important Linux command for Newbies

Published on : January 20, 2012

Author:

Category: Our Blog


My first experience with Linux started when i setup a server for one my client. It was monumental task for me at that time. I was a happy mouse driven windows user. When I came to the world of putty I was lost. So I had to search for certain commands. I recently Setup LAMP With Ubuntu In 10 Minutes. One of my colleague tried to setup LAMP following that post. He was also a happy mouse driven windows user So he was having problem with commands. In this post I am showing all the commands I needed and used to use Linux server. I will post all the problems i faced using LAMP in next post.

To create new directory


mkdir target_director

To copy an entire folder (directory tree) in Linux


cp -ap /var/lib/mysql /mnt/mysql -ap for same permission as source

For checking the size of current folder


du -ch | grep total

To find the size of the hdd


 just enter df

To find out the size of the folder in the folder


du
du -a to show all the file's size

See all files and their size


du -s * -h

To output the number of files in the current directory


ls | wc -l

See all the jobs


ps -aux

To find out RAM size on Linux machine


free

Rename folder/filename


mv test hope
mv *.rtf *.txt

To find which process is consuming how much RAM?


top

To see the free ram memory


free -m

To update yum using corn


0 21 *** usr/bin/yum -y update

Create tar.gz file


tar czvf myfolder.tar.gz abcfolder/

Untar a tar file
tar czvf myfolder.tar.gz abcfolder/

Delete bash History
Try to delete the content of ~/.bash_history

To add new user
* Adding a new user (useradd)
* Modifying an existing user (usermod)

Options:
* -d home directory
* -s starting program (shell)
* -p password
* -g (primary group assigned to the users)
* -G (Other groups the user belongs to)
* -m (Create the user’s home directory


useradd -gusers -Gmgmt -s/bin/shell -pass -d/home/jambura -m jambura

User’s home directory should be 700. If you are operating a ~username type server, the public_html directory should be 777. You may also need to open up the home directory to 755.


 useradd -s/bin/bash -pass -d/imp/sysbsd -m sysbsd

For allowing sudo


 sudo adduser jambura admin

To delete user


userdel user

To display your crontab file


crontab -l

root can view any users crontab file by adding “-u username”


crontab -u bappy -l  # List bappy's crontab file.

* * * * * Command to be executed
– – – – –
| | | | |
| | | | +—– Day of week (0-6)
| | | +——- Month (1 – 12)
| | +——— Day of month (1 – 31)
| +———– Hour (0 – 23)
+————- Min (0 – 59)

Field Allowed values
—– ————–
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

To edit crontab file


crontab -e

#change the editor used to edit file set the EDITOR environmental variable like this:


export EDITOR=/usr/bin/emacs


Leave a Reply

Your email address will not be published. Required fields are marked *