Вы находитесь на странице: 1из 11

Note: To record all your session you can use the

command script.

LAB : 1 SESSION 1
1. Create an user account in your name and your
friend name. (Example: myself, friend1,
friend2,friend3, friend4,friend5)
2. Find out the account is created or not
3. Switch to your account .
4. Login as root
5. Add your account to sudoers file.
6. Find out the group details
7. Change your password.
8. Delete your friend account.
EXPLORE
9. Create 4 groups called Project seminar
friends demo
10.Delete the group demo
11.Add myself, freind1, friend2,friend3 to the
project group

LAB : 1 SESSION 1
1. Find out which shell you are currently using
2. Find all the system defined variables
3. Find the present Directory
4. Change directory to /
5. List the contents of /home directory
6. Create directory in your name.
7. Go to your directory
8. Create a file using vi , gedit called file1, and
file2
9. create an empty file using touch (Ex: touch
filename)
10. list out the files and folders in the current
directory
11. Try ls l
12. To exit from the terminal type: exit

LAB : 1

SESSION 2

Find the difference between .profile and .bashrc


When to use .profile file and when to .bashrc files
What is the difference between /etc/profile and
.profile located in home directory
Add some interactive scripts to those files
EXPLORE :
PS1
PS1 is the variable name
Prompt setting
http://www.bashguru.com/2010/01/shell-colors-colorizi
ng-shell-scripts.html

Prompt escapes
Bash allows these prompt strings to be customized by
inserting a number of backslash-escaped special
characters
that are decoded as follows:
\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue
May 26")
\h the hostname up to the first `.
\j the number of jobs currently managed by the shell
\n newline \r carriage return
\s the name of the shell, the basename of $0 (the
portion following the final slash)
\t the current time in 24-hour HH:MM:SS format
\@ the current time in 12-hour am/pm format
\A the current time in 24-hour HH:MM format
\u the username of the current user

LAB : 1
SESSION -3
1. Suppress the empty line in the file
2. Put lines numbers in the file
3. man and its options
4. Apropos
5. Whatis
6. Which
7. --help
8. Info
9. Help
10. type
11.Whereis
12.Clear the screen

LAB : 1

SESSION 3

1. Find out currently logged in user Hint:whoami


2. Explore date, cal with various options and formats
3. Explore history Hint: history
4. Change the timestamp for the file file1 Hint:
touch
5. List out the files and folders in currently working
directory?
6. Explore : bc
7. What is the alternate command to ls
8. create the shortcut to the command clear Hint:
alias
9. Find the hidden files in the your home directory
10. find the inode number of file1 Hint: ls i
11. Find out the kernel version of your system

Bash colors:
Syntax:
\e[attribute code;text color codem
Attribute codes:
00=none 01=bold 04=underscore 05=blink
07=reverse 08=concealed
Text color codes:
30=black 31=red 32=green 33=yellow 34=blue
35=magenta 36=cyan 37=white
Background color codes:
40=black 41=red 42=green 43=yellow 44=blue
45=magenta 46=cyan 47=white

# swap: Swaps contents of two files


# param1: the file to be swapped
# param2: the file to be swapped
functionswap() # swap 2 filenames
around
{
if [[ -e "$1" && -e "$2" ]]# if
files exist
then
local TMPFILE=tmp.$$
mv "$1" $TMPFILE
mv "$2" "$1"
mv $TMPFILE "$2"
else
echo "\e[1;31mError:\e[0m Make
sure the files exist."
fi
}

Вам также может понравиться