Linux Spoken Tutorial/Basic Level Tutorial Set/Linux-part2

From Process | Spoken-Tutorial
Revision as of 16:30, 9 January 2013 by Sanmugam (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Spoken tutorial on basic linux commands part – 2


Visual Cue
Narration
Show first slide from the presentation Dear friends,

Welcome to the second part of spoken tutorial on basic linux commands In this tutorial we will focus on directory operaions and file permissions.

Show second slide from the presentation First command that we will cover is mkdir. This command creates a new directory in linux file system.
Switch to console and type

mkdir testdir

To create a new directory we will type mkdir tesdir. This will create a new directory called testdir. <pause> Let us now list all sub directories under the current directory and see if new directory has been created.
Type ls and highlight the newly created directory As you can see we success fully create a new directory called testdir.
Stay in console Mkdir can create multiple directories under a given path. When used with -p switch, mkdir will create all the required directories in a given path.
Switch to console and type

mkdir -p /tmp/hello/world

We will now create a new directory called hello in the /tmp directory and another subdirectory called world under the newly created hello directory.
Switch to console and type


ls /tmp && ls /tmp/hello

As you can this command created a directory called hello and a subdirectory called world under hello.
Show slide number 3 Let us now create a directory structure as shown in the figure.
Switch to console and type


mkdir -p tmpdir/{apple,orange,mango/variety/{alphanso,extrema,haden},peach}

Stay in console and type


ls tmpdir && tmpdir/mango/variety

As you can see, we create the required directory with a single command. <pause>
Switch to slide 4 Now lets move to next command. <pause> chown is a command used to change the ownership of a file or directory.
Switch to console To change the ownership of a file or directory, type chown followed by options and filename.
Stay in the console and type


chown root tmpdir

This command will change the ownership of the tmpdir to root user.<pause>

You can specify the oner user and owner group for a file with chown.

Stay in the console and type


chown nobody.nogroup tmpdir

This command will change the ownership of tmpdir to nobody user and nogroup group.
Stay in console and type


chmod -R nobody.nogroup tmpdir

You can change the ownership of all files and subdirectories in a given directory at once, recursively. The -R will make chown change permissions of all files and directories recursively.
Switch to slide number 5 Before moving to our next command, lets look at a unix file permissions. <pause> In unix world, every file and directory has permissions associated with it. These permissions control who can read, write or execute a file or directory.<pause> An user will require execute permission on a directory, if he wants to change directory to a given directory.<pause>

Let us now look at few files and the permissions associated with the files.



Switch to console and type


ls -l

As you can see with every file you have some permissions. <highlight the permission bits in the console>. <pause> First thre e letters will tell you the permissions that owner of a file has <highlight first three rwx bits>. <pause> Next three letters will tel you what permissions the owner group of the file has <highlight next three bits of the permissions> <pause>. Last three letters will tell you what are the permissions for rest of the world.<pause>

A r in first place means you have read permissions on the file.<pause> A w in second position means you have write permission on the file.<pause> A x in third position means you have execute permission on the file.

Switch to slide number 6 Let us now look at chmod command in unix world that lets you change the permissions of a file
Switch to console and type


ls -l abc.txt

You can see that file has only read permissions. Let us add write permissions to the owner of the file.
Stay in console and type


chmod u+w abc.txt

In this command u represents user permissions and plus sign represents adding permissions.
Stay in console and type


chmod a-w abc.txt

To remove a specific permission from a file you have to use minus sign.
Stay in console and type


chmod g+w abc.txt

To add permissions for a group we will use g instead of u.
Stay in console and type


chmod a+w abc.txt

To give write permission to all users, we will use a plus w.
Switch to console and type


chmod -r a+w tmpdir

To grant write permissions to all files in a directory you can use -R option. This option will recursively apply the specified permissions.
Switch to slide number 7 Our next command is chgrp which allows you to change the group of a file.
Switch to console and type


chgrp nogroup abc.txt

To change the group of a file we will type the following command <type the command in the console>
Stay in console and type


ls -l

As we can see the group of the file abc.txt is now changed to nogroup.
Switch to slide number 8 Our next command is rm. This command lets us remove files and directories from the file system.
Switch to console and type


rm abc.txt

To remove a file simply type following command <type the command in the console>.
Stay in console and type


rm -r temp

Rm will not remove a directory by default. You have to specify the -r switch to remove the directory.<pause> You can also force the removal of a file or directory by using a -f switch.
Switch to slide 9 This brings us to the end of the second part of spoken tutorial on basic linux commands. Thanks for watching this tutorial.

Contributors and Content Editors

Sanmugam