I will explain all basics of unix /linux here . Firstly basic directories of unix operating system .
** /bin --> this directory contains all essential files for correct functioning of operating system .all users have permissions of these files .
** /home in this directory all user's home directory resides . This is very commonly used directory .
** /var this directory contains all variables files like logs , db directory etc .
** /etc all system configuration files are stored here .
** /dev additional devices like cd-rom , pendrive , hard disk will found here .
** /sbin binary files , generaly super user uses these files .
** /tmp all temporary files stay here .
These locations are by default . For our ease we can change them also and we can use it .
Linux is case sensitive .
Permissions :-
As linux is multi-user operating system . Every file and directory have permissions defined for every user . Every file and directory have their owner . owner is a user . and also a group . group is group of users .
So we have three different type of permissions .
1) permissions given to owner
2) permissions given to group
3) permissions given to all other users .
And every file have three types of permissions
1) read permission -- those users who have read permission can read the file
2) write permission -- those users who have read permission can write into the file
3) execute permission -- user with this permission can execute the file .
Do ls –l in any directory
Then you will see something like
-rw-r--r-- 1 root root
13 June 5 11:21 file1
Here following will explain this .
r:readable,
w:writable, x: executable
we can use two commands chmod and chown to change permissions and owner of the file respectively .
Now about commands of unix .
One command consists of three parts i.e command name , options , parameters .
example # grep -i "abcds" file.txt
here ,
grep --> command name
i --> option
abcds and file.txt are the parameters of the command .
Options will always start with - mark .
basic commands are :-
command name function
ls show
files in current position
cd change
directory
cp copy
file or directory
mv move
file or directory
rm remove
file or directory
pwd show
current position
mkdir create
directory
rmdir remove
directory
less, more, cat display file contents
man display
online manual
su switch
user
passwd change
password
useradd create
new user account
userdel delete
user account
mount mount
file system
umount unmount
file system
df show
disk space usage
shutdown reboot or turn off machine
sort this command is used to sort
to understand use of any command use man command
man <comand name >
e.g man cp -->> this comand will explain everything about cp
run some commands in your linux/unix machine then you will understand the difference .
ls
ls –a
ls –la
ls -Fa
ls
.bash_profile
cp .bash_profile
sample.txt
less sample.txt (note: to quit less, press “q”)
rm
sample.txt
mkdir linux
pwd
cd linux
pwd
cd
pwd
rmdir linux
ls
.bash_profile
cp .bash_profile
sample.txt
less sample.txt (note: to quit less, press “q”)
rm
sample.txt
df
df -k
df -hk
Paths:- relative and absolute path
Absolute Path :-
Absolute pathe is address from root path . like
/home/linux/
~/linux
Relative path :-
this path is relative to your current path
. / your current location
../ one directory
above your current location
pwd it will show you your current directory
Run following command one-by-one and you will understand
pwd
cd .
pwd
cd ..
pwd
cd ..
pwd
cd
mkdir
mydir
pwd
cd
/Users/invite
pwd
cd
/Users
pwd
cd /
pwd
cd
/Users/invite
cd
~/mydir
Redirect, Append and Pipe
We know output of a command is shown on the screen . i f we want to process the output then we will need some special parts .
Pipe "|" :-
some commands need input from another command or any file .
"|" pipe will help u in giving output of one command as input to another command
Append and redirect :-
'>' this sign will redirect output of a command to a file .
'>>' this sign will append all output to the end of the file.
Please ask in comments if you need any more clearifications .