0% found this document useful (0 votes)
74 views3 pages

Labsheet 0.1

The document provides instructions for a Linux lab session with the objectives of gaining familiarity with the Linux environment and learning basic shell commands. It includes tasks to login and change passwords, and learn elementary commands like ls, mkdir, cd, pwd, cp, mv, rm, clear, man, gedit, tar, and cat among others. Students are instructed to practice using these commands to navigate directories, view files, copy/move files, archive files, and get help documentation.

Uploaded by

Aditya Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views3 pages

Labsheet 0.1

The document provides instructions for a Linux lab session with the objectives of gaining familiarity with the Linux environment and learning basic shell commands. It includes tasks to login and change passwords, and learn elementary commands like ls, mkdir, cd, pwd, cp, mv, rm, clear, man, gedit, tar, and cat among others. Students are instructed to practice using these commands to navigate directories, view files, copy/move files, archive files, and get help documentation.

Uploaded by

Aditya Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab Sheet - 1

The objective of this lab session is to gain familiarity with Linux environment which we will be using
for our programming activities.

Task 1: Login and change password:

Most commands are completed by pressing the enter key (also known as the return key)

1. Login into your Linux computer account using username and password.

2. While in graphical mode, open a terminal. This can be done by clicking the monitor like icon on the
task bar. Or you can right click on an empty portion of the screen and choose ‘Open Terminal’ option.
You are now ready to type commands. You can start multiple terminals in the graphical mode.

4. To change password, type "passwd". Follow instructions that appear. Choose a password that
contains letters and numbers. Note that the password will not be displayed.

5. Remember the new password. That will be the password next time you will use to log in to your
computer.

Task 2: Elementary Linux Shell Commands:

The terminal that we are using is a shell. We need some basic commands to
have our way around in the Linux environment. Try out all the commands and get familiar with these.
To learn more about a command and its options, use the man command (see below).

1. ls: List files and directories in your current working directory.

2. mkdir: This command makes a new directory in the current directory.

mkdir unixstuff
To see the directory you have just created, type
% ls

3. cd: This command changes to the directory mentioned. For example,


cd unixstuff
Type ls to see the contents (which should be empty)
Make another directory inside the unixstuff directory called backups

4. The current directory(.)


In UNIX, (.) means the current directory, so typing
% cd .
This means stay where you are (the unixstuff directory).

-1-
5. The parent directory (..)

(..) means the parent of the current directory, so typing


% cd ..
will take you one directory up the hierarchy (back to your home directory).

6. pwd (print working directory)

Pathnames enable you to work out where you are in relation to the whole file-system. For
example, to find out the absolute pathname of your home-directory, type cd to get back to your
home-directory and then type

% pwd

The full pathname will look something like this -

/home/its/ug1/ee51vn

7. cp: This command can be used to create a copy of a file. e.g.

cp file1 file2 is the command which makes a copy of file1 in the current working directory and
calls it file2

8. mv: This command is used to move a file from one place to another. It is also used to rename a
file.. For example, if we wish to change the name of a file “file1” to “file2”, we can use
$ mv file1 file2

9. rm (remove), rmdir (remove directory)


To delete (remove) a file, use the rm command.
rm tempfile.txt

Use the rmdir command to remove a directory (make sure it is empty first).

10. clear (clear screen)


Before you start the next section, you may like to clear the terminal window of the previous
commands so the output of the following commands can be clearly understood.

At the prompt, type

% clear

11. man: Help for the meaning and usage of various commands. Help is provided for the
arguments given to it, e.g.
$ man ls

12. gedit: This command will start a text editor where you can create, edit and save a file. There
are a large number of editors like gvim etc. You may use any one of them to write your
programs. Open gedit, create a new file, save the file. Check various options available, such as
find/replace, etc.

-2-
13. tar: This command is used to bundle up (archive) many files into a single file.. For example,
place 3 files in a folder named dirname. Go up one level in folder hierarchy by using cd ..
Command. Now use the following command to tar the files –
$ tar -zcvf dirname.tar.gz dirname

14. to untar: In order to untar the file following is to be done:


$ tar -xvf dirname.tar

Note: If extension is .gz after tar ie. filename.tar.gz then use,


$ gunzip filename.gz

15. ls -al: This command will show you files, directories, hidden files(starting with . such as
.bashrc or .bash_profile) along with file permission.
$ ls -al

16. cat: This command is used to view the contents of the file. All lines will be displayed on the
command line one after another
$ cat file1.txt

17. history: This command gives you the entire list of commands typed till the latest command.
$ history

--------- o O o ---------

-3-

You might also like