Sei sulla pagina 1di 23

UNIX

File System Structure

File System Structure cont..


The root(/) directory has a no. of sub directories which serves as reference point for all files. Bin directory consists of all the commonly used unix commands. Sbin directory consists of all the commands can be used by system admn. Only system admn.s path shows these directories.

File System Structure cont..


Dev directory contains all device files. These files does not occupy space on disk. Etc directory contains the configuration files of the system. Lib directory contains all library files in binary form. Tmp directory contains temporary files created by the user.

File System Structure cont..


Usr directory Home directory allows the users to connect through it. Var directory contains all the variable part of the file system.

Unix commands
Mkdir <direcory name>: To create directory. We can create more no. of directories at a time. Ex: mkdir abc xyz pqr creates 3 diff. directories. rmdir <direcory name>: To remove directory. Cd <path>: To change into particular directory by specifying its path.

Unix commands cont..

Mv <dir1> <dir2>: to move dir1 directory under dir2. If <dir1> not exists it creates new directory with name dir1 and move dir1 directory under dir2. If <dir2> not exists then total contents moved to dir2 and dir1 will be collapsed. If both dir.s not exists then dir1 will be created under dir2.

Unix commands cont..


Pwd : to show the name of the current working directory. Ls: to list all the directories in the current directory. Tty : to show the name of the terminal. Who: to show all the users currently using the sytem.

Unix commands cont..


cat command:- There are four uses of cat command.One is to create new file and to display the contents of an existing file.And it is also used to append text to an existing file and also to concatenate the contents of two files and store them in the third file. Ex1:-$cat >test Unix is a multiuser operating system ^d The above command is used to create a file called test

cat command cont..


Ex2:-$cat <test Unix is a multiuser operating system The above command is used to display the contents of a file called test. Ex3:-$ cat >>test Unix is a multitasking operating system ^d The above command is used to append text to a file called test.

cat command cont..


Ex4:-$cat test sample>sam This would create sam which contains contents of test followed by that of sample.If sam already contains something it would be overwritten. If we want that it should remain intact and contents of test and sample should get append to it then we should use the append output redirection operator ,>> as shown below: Ex5: $cat test sample >> sam

cp command
cp command:- This command is used to copy the contents of one file into another file. Ex1:-$cp test test2 This will copy the contents of test into a file test2.If test2 does not exist,it will be created.However,if it does exist,Unix takes the liberty to overwrite it without warning you.

cp command cont..
Ex2:- $cp test test2 josh_dir In the above command,all files mentioned are copied to the indicated directory.Provided that the directory josh_dir exists,both files test and test2 would be copied to it.

Rm command
rm command:- This command is used to remove the specified file or directory. Ex1:-$rm -I filename The above command is used to remove the given file.i.e you are asked for confirmation before deleting the file. Ex2:-$rm r directoryname This command recursively (-r) removes all contents of the specified directory and also specified directory itself. Ex3:-$rm f file This command would delete files forcibly. Ex4:-$rm a*.c The above removes all files with extension c and whose filename starts with a file.

mv command
mv command:- This command is used to rename the Ex1:- $mv sample josh Ex2:- $mv *.c /tmp The above command is used to move all files with extension c in current directory to /tmp directory. Ex3:-$mv /bin/* /tmp The above command is used to move all files of /bin directory to /tmp.

Unix commands cont..


Wc: to count the no. of words in a file. Date: to display the date. Find: to search a file in the current directory.

Security By File Permissions


At the file level, there are read, write and execute permissions to each file which decide who can access a particular file, who can modify it and who can execute it. The existing file permissions can be changed by the owner of the file or by the superuser.

Security By File Permissions cont..


There are three types of permissions to a file Permission Weight Read(r) 4 Write(w) 2 Execute(e) 1 Example:$ls l sample

-rwxrw-r-sample 1 vrec vrec 24 Feb 06 10:23

Security By File Permissions cont..


Here the permissions for the file sample from the long listing are rwxrw-r--.In the above example the leftmost character (in the file permission) - indicates that the file is an ordinary file. Next 9 characters indicates permissions of a file. Of the nine characters. The first three characters decide the permissions held by owner of the file. In the above example the owner can read ,write as well as execute the file sample.

Security By File Permissions cont..


The next set of three characters specify the permissions for the members of the group to which the file owner belongs.In above example the members of the group can read and write the file but cannot execute that file. A indicates that the permission is denied. While the last set decides the permissions for the users outside the group (Others).In the above example all others can only read that file.

Security By File Permissions cont..


Permission Read(r) Write(w) Execute(x) Read and write(rw) 4+2+0=6

Weight 4 2 1

Security By File Permissions cont..

Ex:-$chmod 777 sample $ ls l sample


1 vrec vrec 23 Feb 06 10:56

-rwxrwxrwx sample

Ex3:-$chmod 654 sample $ls l sample


vrec vrec 23 Feb 06 10:56 sample

-rw-r-xr-- 1

THANK YOU!!!

Potrebbero piacerti anche