Linux Commands a useful list that everyone should have.

Advanced ShoutCast Hosting

Hi Folks, 

Came across one of the best looking blogs I have seen in some time maintained by a guy called Yasir which you can see here: http://killershock.online.fr 

He said it would be ok to repost some stuff and I really like this list. 

Enjoy 😀 

Linux Commands 

Getting used to Linux seems to be a daunting task for Novice users as it is considered as a completely different exposure to an environment. In fact, the Linux Terminal (after the kernel) is the root of the system since it is a means of system administration and here you’ll learn some basic commands which are followed by a brief description of its utility. 

lpr file.ext   

 

Send the filename “file” with extension “ext” to the printer 

ls -ar   

 

List all files in the current directory using recursive mode 

cd /etc/   

 

Switch to the directory /etc 

who   

 

List users who are currently logged in 

tty   

 

List active Terminals – There are up to 7 terminals on Linux. You can switch to e.g terminal 5 by Holding ALT and Pressing F5 

cp file1 file2   

 

Duplicate file1 – Give it the name file2 

system-config-display   

 

Configure the display – Triggers the display manager using the above command 

cat /etc/fstab   

 

Display contents of the file /etc/fstab to the terminal 

rm file1.txt   

 

Delete file1.txt from current directory 

pwd   

 

Prints Working Directory – Tells the user the current directory 

mkdir dir1   

 

Create directory dir1 – Note Directory are case-sensitive Dir1 and dir1 are not the same 

rmdir dir1   

 

Deletes the Directory dir1 

useradd user1   

 

Adds a new user names user1 

userdel user1   

 

Deletes user1 from the system 

passwd user1   

 

Sets the password of user1 

su user2   

 

Switch to user2′s profile – Terminal will prompt for password if user2 is password protected 

groupadd hello   

 

Creates a new group called hello 

groupdel hello   

 

Deletes the group hello 

ln file.txt /home/user/Desktop/file2.txt   

 

Creates a hard link, in other words if file1.txt is deleted file2 is not and contains contents of file1.txt 

ln -s file1.txt /home/user/Desktop/file2.txt   

 

Creates a soft link – A shortcut! if original file is deleted shortcut cannot like to original file 

ps -ax   

 

Lists all processes and their pid 

ps axjf   

 

Prints a process tree – Parent and Child Process format 

kill -9 2304   

 

Sends signal SIGKILL (-9) to pid 2304. In other words, kills the process 2304 

Having fun yet?? 😀 

The following are for slightly more advanced users but allways good to have handy: 

Changing File Permissions 

chmod +x file1.sh    

 

Set file1.sh to executable mode. In other words, typing ./file.sh in the terminal will execute the script. To make the file read, write and executable, running the command chmod +rwx file1.sh will do so. Additionally if the file was set to read, write and execute and you want it to be read-only, chmod -xw file1.sh will do the trick. 

Note: 

  • r stands for read
  • w stands for write
  • x stands for execute
  • introducing +w will introduce write mode while -w will remove write mode. This is same for other switches like x and r

 

Finding files 

locate fstab    

 

This command will list the locations where the expression “fstab” was found. Alternatively if you are looking for the file fstab the following command will help you out. 

find / -name fstab    

 

Notice the “/” and the switch “-name”. The “/” tells the find command to look in the root directory while “-name” switch tells find to locate the filename. The above command returned the following 

/etc/fstab
/usr/share/doc/mount/examples/fstab    

 

Advanced File Display 

head /proc/cpuinfo    

 

Returns the first 10 lines of the file /proc/cpuinfo. Alternatively head -n11 /proc/cpuinfo will return the first 11 lines of the file. 

tail /proc/cpuinfo    

 

Returns the last 10 lines of the file /proc/cpuinfo. Using the command tail -n12 /proc/cpuinfo will return the last 12 files of the file /proc/cpuinfo 

more /proc/meminfo    

 

This will allow the user to scroll from top to bottom of the screen. Use the enter key to scroll down. 

less /proc/meminfo    

 

Allows scrolling through the screen in both directions (UP and DOWN) using the ENTER, Page UP and Page Down Keys. 

Listing Hardware Information 

lsusb    

 

Lists usb devices/buses 

lspci    

 

Lists pci devices 

lshal    

 

Lists HAL(Hardware Abstraction Layer) devices. 

Memory Information 

free    

 

Displays information about physical memory and swap space. 

top    

 

Displays real time memory usage (see screenshot below) 

Linux Memory Usage 

Linux Memory Usage    

System Shutdown and Restart    

The piece of information below has been used with permission from geekscribes.    

shutdown [- shutdown parameters] [ time parameter] [ optional message ]

shutdown parameters: r = reboot, h = halt, c = cancel shutdown (time parameter is then not required)

Some examples:

shutdown -r now    <-- Reboot immediately
shutdown -h 19:00  <-- Shutdown (Halt) the system at 19h
shutdown -h +5 "System will shutdown"   <-- Shutdown the system in 5 mins from now, and tell users why.

Advertisements

2 Responses

  1. Thanks for the comment, if you ever want to do any guest blogging let me know 😀

  2. Ah that’s great all my contents are distributed under GNU GPL, allowing users to put them in their own words.

    I will drop by and learn new things from your blog

    Regards,
    Yasir

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

%d bloggers like this: