Showing posts with label commands. Show all posts
Showing posts with label commands. Show all posts

Wednesday, September 23, 2015

Getting started with UNIX - Basic commands


List of basic commands of unix

reboot - Immediately stops all running processes, shuts down the system, then reboots.
sudo - Runs commands as root, which means no limitations due to permissions.

shutdown - Stops all running processes and shuts down the system.
Parameters can be specified to issue a delayed shutdown or a shutdown at a particular time.

date - Prints out the current system date and time.
Specified parameters can change the format of the output.

df - Reports the disk space usage for the file system.
hostname - Displays the name of the current host system.
ps - Displays information about all of the processes currently running on the system.
du - Disk usage
ps - List running processes

To know the process id of a process running
 ps -elf | grep process_name
 ps -fA | grep process_name

| -> pipe character is very useful for redirecting output of one command to other
 grep is used to find the pattern

To create a file
 cat filename
 touch filename

To search something in a file
 grep -i thing_to_be_searched filename

To search something across directories
 grep -rn pattern_to_be_searched directory_starting_from_where_search_to_be_started 

To view processes along with the memory they are consuming run
 top
Ctrl + M will sort in decreasing order of memory consumption

chmod / chown - Changes the access permissions of one or more files (chmod) or
changes the ownership of a particular file to a new user (
chown).
Only users with permission or ownership of a file can change that file’s permissions or ownership.

chown owner_name filename
chmod 755 filename  

Here 7 is the permission for owner
5 and 5 for group and others respectively

7 - xrw
5 - xr
2-r
4-x
1-w

Access permissions are of three types
 x Execute permissions (4)
 r Read permission (2)
 w write permissions (1)

Aur linux has concept of owner, group and others.

Owner is the owner of the file
Every file or directory belong to a group
And third is others(not owner and not belonging to the group of the file)

Permissions are in the order Owner permissions Group permissions  others permissions