Unix Commands

Below are some useful Unix commands: -

A directory is a collection of files, like drive or folder in windows.

The directory structure of a Linux machine is as below: -

/home --> home directory of the user.
/var    --> used to store log files are present here in folder /var/log.
/etc    --> used to store configuration files. Ex- /etc/puppet.conf  etc.
/tmp   --> used to store temporary files.
/opt    --> used to store/install third party software like java. By default, its used.
/lib     --> used to store library files.
/root   --> home directory of root. root is administrator of Linux machine and has highest privileges. 
/bin    --> to store binary files.
/dev --> to sore device files. e.g. /dev/sda , /dev/sdb etc.

When a user logs in to a Linux machine, automatically he will be in: -

/home/user1 directory
User1--> /home/user1

How to login a linux machine/server:-

To login you have provided with ip address, username, password.

To login we need a software called "putty". If you don't have you can download from google.

putty ==> to login a remote machine

ssh/telnet ==> protocol to be used

ip address or hostname
server1.in.ibm.com --> hostname --> ip address

In earlier stage we have applications running in an operating system which is installed in a server.

Here the problem is there is CPU loss, memory loss. So we come up with below approach 
where we can have multiple machines can use the same operating system running in a single sharing server. These are called virtual machines.

vm1, vm2, vm 3

ls --> to see list of files in a folder.
 In linux each command can have arguments, to perform different behaviour.
ls -l --> long list of files. It will display long list file details
 rwx...... i root 1457 Apr 21 23:23 original-ks.cfg
ls -l / --> it will give directory structure of a folder
ls -lrt --> This will display the list of files based on timestamp modified in reverse order or descending order.
clear --> to clear the screen
mkdir --> to create a directory.
mkdir test --> will create a directory test.
mkdir -p /a/b/c/d/e --> This will create folder inside a folder directly. This will create e folder directly by creating a, b, c, d folder in single shot.
pwd --> present working directory
cd --> change directory
cd test - will move me to test directory.
cd .. --> to take present directory to one level up.
touch --> to create a dummy files.
touch 1 2 3 --> it will create dummy files 1 , 2 , 3.
rm --> to remove/delete file.
rmdir --> delete a directory if folder is empty.
rm -rf --> to remove all files recursively and forcefully
 r-> recursively
 f-> force
rm -rf /a --> to remove all the directory and files in folder recursively.
 This is very dangerous command in Linux. There is nothing like recycle bin in Linux. So you will never get back the file.
rm -rf / ===> all folders will be gone and your Linux machine will be screwed up.
cp -->  copy a file or folder
cp file file123 --. This will create another file123 and copy contents from file.

cat --> to list out all the contents of a file.
suppose we have a file called '2' which contains a text 'hello world'
cat 2 -> it will display all the contents of file 2.
hello world