22
Linux Desktop Usage

02 linux desktop usage

Embed Size (px)

DESCRIPTION

Unix / Linux Fundamentals

Citation preview

Page 1: 02 linux desktop usage

Linux Desktop Usage

Page 2: 02 linux desktop usage

Linux Desktop Usage• Upon boot-up completion of a Linux system, a “login” prompt

will be displayed; username is to be input here and the password in the “password” prompt.

• Note that no marks at all are written into the prompt line when typing in the password, that is normal.

• A successful login will result in receiving the shell (Linux command line interface) prompt; the default shell in many modern Linux distributions is Bash (Bourne Again Shell) which is a newer and improved version of ‘sh’.

• There are several other alternatives for Bash TCSH CSH KSH

Page 3: 02 linux desktop usage

Logging into Linux• The login process is the identification and authorization of a

user in the system.• Multiple users are allows to log into the same system

simultaneously.• The username and password provided are checked, by

default, against these three files: /etc/passwd: this file keeps a listing of all the currently existing users

on the system; users and their properties, such as home-directory location and default shell can also be edited in this file.

/etc/shadow: this file encrypts and contains the passwords to all of the system’s users; it can also be used to manage password properties such as setting the interval in which the password needs to be changed, make the password inactive, etc.

/etc/group: this file lists and manages the groups on the system and the assignment of users into groups.

Page 4: 02 linux desktop usage

Logging into Linux• Logins to the system can be performed on the local machine

either in Command Line or GUI mode and Remote Terminal software such as PuTTY

• When a user logs in from a terminal software, whether remote or local on the machine, a “pseudo-terminal” is activated and is represented in the system as pts/0, pts/1, pts/2 and so forth, depending on the amount of sessions open concurrently.

• The pseudo-terminal is a piece of software that emulates old keyboard and screen terminals in order to allow full support on both modern and old systems, such as UNIX.

Page 5: 02 linux desktop usage

Running Shell Commands• Linux(UNIX) is case sensitive. Most command names are

lower case• Commands starts at the beginning of the line• Commands and arguments are separated by space(s)

Commands are terminated by <CR> (The value of Enter)• In most cases, the location of each argument is not relevant

and single character arguments, can be merged

$ ls $ ls –l -r -t$ ls -t -r -l

$ ls -ltr

Page 6: 02 linux desktop usage

Running Shell Commands• When a command is running, use the control sequences to

manage it’s runtime– CTRL-c Terminate the running program– CTRL-z Suspends the running program – fg makes suspended program return– bg makes suspended program return and send output to the back-

ground– jobs list all currently running jobs on the current terminal

Page 7: 02 linux desktop usage

System information• Several basic commands can provide information about which

system you are connected to, which account you are using and what is your system type– uname [option(s)] print system information, such as name, type,

version and hardware architecture– id [option(s)] print information about the connected user account– tty print the terminal name for this session– who print the list of active user sessions

Page 8: 02 linux desktop usage

The Shell Prompt• A standard shell prompt looks like this:

[user1@CentOS-LAB ~]$

• The first section is the username of the user currently logged into the shell, in this case it is “user1”.

• “@” separates the username and the hostname of the Linux machine, in this case the hostname is “CentOS-LAB”.

• “~” report the current working directory• “$” represents a regular user

“#” is used when you are logged-in as the ‘root’ user• The prompt can be customized and even colored.

Page 9: 02 linux desktop usage

Switching Users• In order to switch between users in an active system that we

have already logged-in to, we’d use the “su” command, for example to switch from the user “user1” to the administrative user “root”, we will run the following command: $ su -

Password: #

• When running “su –” without specifying any other username to switch to, the command defaults into switching to the user “root” and prompts for the root password.

• Once the root password has been successfully provided, the user has been switched to “root” and the user now has all the administrative privileges of “root”.

Page 10: 02 linux desktop usage

Switching Users• Switching to another regular user is done the same as

switching to root with the addition of the desired username in the command line:$su - testPassword: $

• As the example above shows, the user “user1” has now switched to “test”, any action performed on the system now will be logged as user “test” and either allowed or denied, depending on that user’s permissions and privileges.

Note: While logged-on as “root”, the “su” command can be used to switch to any regular username in the system and no password will be asked since “root” is the all-mighty.

Page 11: 02 linux desktop usage

Editing Text Files• Some of the common text editors for Linux are:

VI VIM EMACS Nano

• VI is the default editor for Linux and UNIX systems• On newer distributions we are likely to find VIM, which is “Vi

Improved”. Newer and better version of VI including features like syntax highlighting

Page 12: 02 linux desktop usage

Editing Text Files• For this example, we will edit a file named “testfile” which

resides under the “/tmp” directory; the example will also use VIM as the text editor of choice.

• First, we run VIM while defining which file we wish to edit; if the file does not exist in the specified location, VIM will create a buffer in which all the new text we type is kept until we actively save the contents into an actual file, however if we do not save the contents, they will be lost upon quitting VIM.

• Run the following command to enter VIM: $ vim /tmp/testfile

Page 13: 02 linux desktop usage

VIM Command/Navigation• VI has three operation modes

– Navigation: In this mode we are able to navigate between words and lines in our text file; navigation in VIM is performed using the arrow keys

– Insert: In this mode we can add, remove and edit text– Command: VI Command Line

When in Navigation mode, use “CTRL” and the right or left arrow keys to jump whole words right to beginning of the next or previous word

Page 14: 02 linux desktop usage

VIM Command/Navigation• VIM has many different commands and shortcuts that can be

used while editing to make the process faster and easier for the user; here’s a short list of basic actions: e: jumps to the end of the current word. b: jumps to the beginning of the current word. 0: jumps to the beginning of the current line. $: jumps to the end of the current line. H/M/L: jumps to the first, middle or last line of the currently viewed

page on screen, respectively. :<n> : jumps to line number <n> in the file, for example :10 will jump

to line number 10. u: undo the last action. CTRL-r: redo the last action.

Page 15: 02 linux desktop usage

VIM Insert• Insert mode: accessing insert mode in VIM can be done in a

few ways: Hitting the “Insert” keyboard button. Hitting the “i” keyboard button.

• Once in insert mode, the word “– INSERT –” will be written at the bottom of the screen, this is the marker you are now in edit mode and can type in any text you wish as plain text.

• Insert mode has another sub-mode which is called “Replace”; hitting the “Insert” key a second time while in insert mode will go into “Replace” and “– REPLACE –” will appear in the bottom of the screen, this mode allows overwriting any text in the position of the cursor.

Page 16: 02 linux desktop usage

VIM Save / Quit• After the file has been created or edited it needs to be saved;

in order to do that, we first must return to command/navigation mode by hitting the “ESC” key twice, the INSERT or REPLACE marker will disappear from the bottom.

• While in command/navigation mode, hit : and a marker will appear in the bottom, this initiates and command line mode VI commands: w save changes to file q quit VI wqIn case you want to do something that VI recommends against, use the

optional ! to force your command

Page 17: 02 linux desktop usage

Linux Help & Documentation• The vast majority of Linux packages/applications arrive with

built-in documentation.• There are number of ways to view different types of

documentations of an application: The info command: displays general information about the

application, for example run: info ls The man command: displays the manual and usage document of an

application, this document usually describes what the command does, breaks down and explains in-depth each of its options, flags and arguments and in many cases also provides syntax examples to that command; for example: man ls

The –help / -H argument: almost every comamnd in Linux has a set of options / arguments it can receive; one of these options is –help or –H which will display a summary of all the possible options that command can take, right in the command line. Try running: ls --help

Page 18: 02 linux desktop usage

Linux Help & DocumentationDirectories and files under ‘/usr/share/doc/’. Most

application has many optional documentation, examples and README files under this folder. This can help you find answers you can not find in ‘man’ or ‘info’

Page 19: 02 linux desktop usage

Linux Help & Documentation• Reading the manual and documentation usually includes

understanding the Syntax declaration of a specific command. When reading a Syntax declaration, it is highly important to notice the different signs and characters and understand their meanings:mkdir [-pv] [-m mode] directory_name ...– The first words stands for the commands name.– ‘[ ]’ - Optional flags/parameters to the command– param - Mandatory parameters– … - The last parameter can be repeated multiple times

Page 20: 02 linux desktop usage

Linux Help & Documentation• ‘man’ is of the most power-full assistance a Linux user can

have. It has all of the information needed in order to run the different commands, all updated to the current version of the Operating System

• Use ‘man -k {keyword}’ to find all manual pages which contains ‘keyword’ in their name or description

• When viewing a manual page, the most important thing to notice is the ‘section’ in which this page is.Review the first (upmost) line of the manual page to get the section number and name. e.g.

“PASSWD(1) BSD General Commands Manual PASSWD(1)”

Page 21: 02 linux desktop usage

Linux Help & Documentation• When running ‘man’ use the following syntax to choose a

section: ‘man [section_number] {manual_name}’

• The ‘whatis’ command, can be used to get the starting lead when trying to figure out what a command does(in case you know the exact command name)

Page 22: 02 linux desktop usage

Linux Help & Documentation• Aside from the built-in documentation, there is a great deal of

information online on Google, Wikipedia and numerous other websites, such as: www.linux.com www.linuxforums.org www.linuxquestions.org www.unix.com www.howtoforge.com www.justlinux.comAnd many others.

• These websites contain information varying from general explanations to detailed how-to guides and answers to real problems other users have experienced and asked about.