chapter 5 first step with linux

20
Chapter 5 First step with Linux

Upload: oceana

Post on 23-Feb-2016

75 views

Category:

Documents


0 download

DESCRIPTION

Chapter 5 First step with Linux. Linux users . There are three types of users in linux System users: (they are the software/applications users created automatically by the system) e.g mail , MySQL , ftp ….. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 5 First step with Linux

Chapter 5First step with Linux

Page 2: Chapter 5 First step with Linux

There are three types of users in linux

System users: (they are the software/applications users created automatically by the system) e.g mail , MySQL , ftp …..

Super user: (the superuser/root user/system administrator is only one, his duties are to install software + create or delete users + look after the system resources ….) the prompt sign of super user is # in all shells .

Normal users: (the normal users can me many , the powers of normal users are limited but normal user has full powers in his home directory ) the prompt sign of normal users in $ in bourne shell and % in c-shell

Linux users

Page 3: Chapter 5 First step with Linux

List down files and directories ls =list down all the files and directories.

ls –a =It will list down all hidden the files and directories

ls –la =It will list down all hidden the files and directories in detail

free =It will show the used , free and total memory of the

system.

Some basic commands

bin dev home lib etc myfilea mYfilea myFilea mnt usr myhomedirbk17oct2013.tar

.profile .login bin dev home lib etc myfilea mYfilea myFilea mnt usr myhomedirbk17oct2013.tar

-rwxrwxrw- 1 root root 5 aug 2008 17:34 .profile drwxrw-rw- 2 root root 8 aug 2010 12:34 bin -r—r—r-- 1 usman ali 14 sep 2005 05:12 Myfilea

Page 4: Chapter 5 First step with Linux

tree -dx // |--bin|--boot|--dev|--etc|--home| |--bilal| |--abid| | |--myfolder| |--usman|--misc|--lost+found|--mnt|--opt|--root|--sbin|--usr

Some basic commands

This command will display all the directories ‘first level’, +subdirectories ‘second level’ ,++subdirectories ‘third level’ and so on .It will also display files

Page 5: Chapter 5 First step with Linux

• / “native root” – It is the main directory in which all the rest linux directories are located • /bin -It requires about 550mb of space, contain essential commands used by the system when running and booting Linux. • /sbin -It requires about 550mb of space, contain essential commands used by the system when running and booting Linux.• /boot -It contains Linux kernel which is loaded at boot time.It also contain files that contain information for booting Linux. • /dev -It contains 7500 files representing devices.• /etc -It contains more then 20mb system configuration files and directories .Containing some major software packages like apache , Openssh and passwd file. • /home -It contains the directories of all the normal users, when ever a new user is created then automatically a directory will be created by his/her name inside home directory. when ever a user will login then he/she will automatically will jump in his/her home directory.• /proc -It only exist while Linux is running and it shows different memory usage. • /usr -It is approx 5GB in size and contains software applications and libraries.• /tmp -it is used for temporaty file storage.The tmp directory is cleaned of each day and will delete files that are not used for 10 days.• /var -It contains directories and sub directories used by various system services e.g mail , ftp etc…

Directory structure

Page 6: Chapter 5 First step with Linux

When you login to the system a session is established and when you logoff the session is ended.

Different ways to login

You can connect and establish a session by using keyboard, monitor and a mouse attached to your pc.

You can connect by dial-up modem and establish a session. You can connect through a wired network and establish a

session. You can connect through a wireless network and establish a

session.

Session (log in and log out)

Page 7: Chapter 5 First step with Linux

Stand alone pc Requirements: • User (optional) • Password (optional)

Local Area Network pc Requirements:• User• Password• System name or IP address

Wide area Network Pc Requirements:• User• Password• System name of IP address• Port number (optional, default ports ftp 21,telnet 23,ssh 22)

Session Requirements (log in and log out)

Page 8: Chapter 5 First step with Linux

Working with Consoles Increasing the number of consoles/terminals• F1,F2,F3,F4,F5,F6 ….

Jumping back to the precious terminal or another terminal• Alt+F4

• Alt+F3

• Alt+F1

Session

The first console by default name is vt1 and if You increase there number , they will be given a name by the system like vt2, vt3,vt4…

Page 9: Chapter 5 First step with Linux

To end a Session

Session

COMMANDS• logout• exit • Ctrl+D

Page 10: Chapter 5 First step with Linux

Secure Shell

Session The best and the most secure way to log in a remote Linux computer is to use SSH(Secure Shell), it has two parts(server side ssh and client side ssh).

Client side windows ssh Server side linux ssh

Page 11: Chapter 5 First step with Linux

Some important commands of this chapter• chfn -To change the user information such as address,phone,email.… e.g chfn usman• finger –To view the user information e.g finger usman .• grep usman /etc/passwd –once the user information is changed , automatically the changes will be made in passwd file which contains the latest information of all the users. The command grep will only find out the information of the user usman.• apropos -It will display the command related information. e.g apropos partition . • man -It will also display the command related information. e.g man date. (already done )• whereis -It will find out the command and its documents on the entire file system and will display the output along with the path e.g whereis fdisk . • links -It will display html pages not in only text mode, but in a slightly better GUI. This command is also helpful if the web browser is not working then you use links command to browse the pages. e.g links /home/umar/myweb/index/html • which -It will display the information of a shell, e.g which tsch• chsh -To change a shell. e.g chsh –s /bin/tsch or chsh –s /bin/csh. the option –s is used to set the new shell . • env -To view the environment “settings” of a user, the home directory path, the shell which the user is using, the by default language etc…. e.g env

Commands

Page 12: Chapter 5 First step with Linux

Back to user Home directory When ever a new user is created, linux will automatically create a folder by exact user name on the path /home• cd -To move and to go into the home directory of a user. If user usman is on the path /home/ali and he want to go to his home directory which will be /home/usman then he will type the command cd

• cd $HOME -To move and to go into the home directory of a user. If user usman is on the path /home/ali and he want to go to his home directory which will be /home/usman then he will type the command cd $HOME

• cd ~ -To move and to go into the home directory of a user. If user usman is on the path /home/ali and he want to go to his home directory which will be /home/usman then he will type the command cd ~

Commands

Page 13: Chapter 5 First step with Linux

Removing/creating files and directories + meta charactor • rm -To remove a file. e.g rm file21

• rm –R -To remove a directory and all the files and subdirectories inside e.g rm –R mydir33 • rm file* -It will remove all the files starting from the name file no matter how lengthy there name is, will remove file1, file111, fileabc43er, fileg * is a meta character which has a special meaning behind it (meaning every thing) • rm file? -It will remove all the files starting from the name file and just one more extra character in the name, will remove file1, fileB, filec, file8. ? again is a meta character which has a special meaning behind it (meaning just one character or letter), it acts like a fill in the blank• rm f?l? -It will remove all the files starting with the first letter f and the second may be any character/number ,third letter must be l and fourth may be any character/number f just one more, will remove file, fBl2, f5l7, f9le, f3lg. ? again is a meta character which has a special meaning behind it (meaning just one character or letter), it acts like a fill in the blank, in this example there are two fill in the blanks• touch -It will create an empty file, e.g touch mynewfile

• mkdir -It will create a directory ,e.g mkdir mydir32

Commands

Page 14: Chapter 5 First step with Linux

Creating and Extracting tar files To combine many files and directories into one folder

Creating (-c creating a file, -f file name,-v “verbose”, verbose will display ongoing progress,-z zip a file)

Extracting (-x extracting a file)

Tar files (tar)

Command Option End Result Target Foldertar -cf mybkdir24sep13.tar mybkdir24sep13tar -cvf mybkdir24sep13.tar mybkdir24sep13tar -czf mybkdir24sep13.tar.gz mybkdir24sep13

Command Option Target Foldertar -xf mybkdir24sep13.tar tar -xvf mybkdir24sep13.tartar -xzf mybkdir24sep13.tar.gz

Page 15: Chapter 5 First step with Linux

Name of the editor command to open screen shot Pico file editor pico myfile

CTRL X to exit

Working with file editors Pico

Page 16: Chapter 5 First step with Linux

Name of the editor command to open screen shot vi file editor vi myfile

:q to quit :w to save :wq to save and exit

I -going to insert mode Ecs -going to command mode

Working with file editors vi

Page 17: Chapter 5 First step with Linux

Name of the editor command to open screen shot Emacs file editor emacs myfile

Working with file editors Emacs

Page 18: Chapter 5 First step with Linux

File permissions

Page 19: Chapter 5 First step with Linux

chmod 777 myfile Will assign read, write and execute permissions to all owner, group and others (rwxrwxrwx) chmod a+rwx myfile will assing read, write and execute permissions to all owner, group and others (rwxrwxrwx) chmod g-rx myfile will retrieve write permissions from group(rwx-w-rwx

chmod -R 644 root will assign read and write permissions to owner and read permissions to group and others , this permission will be effected on the directory as well as all the subdirectories and folders residing inside root (rw--r--)

File permissions Giving file permissions to files and directories

Command -option argument description

Page 20: Chapter 5 First step with Linux

Creating a User useradd bilal

Assigning a password to a User passwd bilal

************Default new user settings

useradd -D [- options] [-g] [-s] Deleting a user add users home directory as well userdel –r bilal

‘-r’ /home/bilal

Creating and Deleting User