Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Installation and Administration Lesson 2 Tutor: George Papamarkos.

Similar presentations

Presentation on theme: "Linux Installation and Administration Lesson 2 Tutor: George Papamarkos."— Presentation transcript:

1 Linux Installation and Administration Lesson 2 Tutor: George Papamarkos

2 Lesson Outline Getting help in Linux –Using ‘man’ command Shell Prompt Basics Linux Authentication Settings –Working as ‘root’ –Managing users and groups Getting System Information –Memory/CPU Usage –Disk Usage

3 Getting Help Applications, utilities, and shell prompt commands usually have corresponding manual pages (also called man pages) Man pages show the reader the available options and values of file or executable. Man Pages can be accessed via shell prompt by typing the command man and the name of the executable. E.g. man ls to see the manual page of ‘ls’ command

4 Getting Help (cont.) The NAME field shows the executable's name and a brief explanation of what function the executable performs. The SYNOPSIS field shows the common usage of the executable, such as what options are declared and what types of input (such as files or values) the executable supports. The DESCRIPTION field shows available options and values associated with a file or executable. See Also shows related terms, files, and programs. To navigate the man page you can use the [Page Down] and [Page Up] keys or use the [Spacebar] to move down one page and [B] to move up. To exit the man page, type [Q]. To search a man page for keywords type [/] and then a keyword or phrase and press [Enter]. All instances of the keyword will be highlighted throughout the man page, allowing you to quickly read the keyword in context.

5 Shell Prompt Basics Create a directory – mkdir Copy a file from one dir to another – cp Make a copy of a file with another name – cp Move a file – mv Rename a file – mv Remove a file – rm

6 Shell Prompt Basics (cont.) Determining your current directory by 'pwd' command: – $ pwd /home/gpapa05 Create a directory with 'mkdir' command – $ mkdir E.g. mkdir lesson2 Change Directory with 'cd' command $ cd lesson2 $ pwd /home/gpapa05/lesson2

7 Shell Prompt Basics (cont.) View directory contents with 'ls' command The following is a short list of some options commonly used with ls. Remember, you can view the full list by reading the ls man page (man ls). -a — all. Lists all the files in the directory, including the hidden files (.filename). The.. and. at the top of your list refer to the parent directory and the current directory, respectively. -l — long. Lists details about contents, including permissions (modes), owner, group, size, creation date, whether the file is a link to somewhere else on the system and where its link points. -F — file type. Adds a symbol to the end of each listing. These symbols include / to indicate a directory; @ to indicate a symbolic link to another file; and * to indicate an executable file. -r — reverse. Lists the contents of the directory from back to front. -R — recursive. This option lists the contents of all directories below the current directory recursively. -S — size. Sorts files by their sizes.

8 Shell Prompt Basics (cont.) Linux has a utility which can help you keep short lists, gather lists together, and even show you information about your system. The utility is called cat, short for concatenate, which means to combine files. The command cat will also display the contents of an entire file on the screen (for example, type cat filename.txt). If the file is fairly long, it will quickly scroll past you on the screen. To prevent this, use the ‘cat filename.txt | less’ command. The ‘grep’ command –The grep command is useful for finding specific character strings in a file. –For example, if you want to find every reference made to "coffee" in the file sneakers.txt, you would type: grep coffee sneakers.txt

9 Shell Prompt Basics (cont.) – Pipes and Pagers In Linux, pipes connect the standard output of one command to the standard input of another command. E.g. ls -al /etc | less Redirects the output of the ‘ls’ command to the ‘less’ command. (Try it out) Pipes can also be used to print only certain lines from a file. E.g. – grep coffee sneakers.txt | lpr This command prints every line in the sneakers.txt file that mentions the word "coffee" The ‘more’ command –Similar to ‘less’ command –The main difference between more and less is that less allows backward and forward movement using the arrow keys, while more uses the [Spacebar] and the [B] key for forward and backward navigation.

10 Shell Prompt Basics (cont.) The ‘head’ command –You can use the head command to look at the beginning of a file. The command is: head The ‘tail’ command –The reverse of ‘head’ command. Using tail, you can view the last ten lines of a file –Using the -f option, tail automatically print new messages from an open file to the screen in real-time –E.g. tail -f /var/log/messages Wildcards and Regular Expressions –Using wildcards or regular expressions, you can perform actions on a file or files without knowing the complete filename. –Wildcards are special symbols that you can substitute for letters, numbers, and symbols –E.g. ls s*.txt will result all the files in the current dir that start with ‘s’ and are suffixed with ‘.txt’ –Here is a brief list of wildcards and regular expressions: * — Matches all characters ? — Matches one character in a string \* — Matches the * character \? — Matches the ? character \) — Matches the ) character

11 Create a user account Creating a user account –You should avoid working in the root account for daily tasks –In case that you want to perform a task that requires root privileges use the command ‘ su – ’. You will be asked to provide the ‘root’ password. If everything goes fine you will get a root prompt –You HAVE TO create a user account to work on –Two ways to create a user Graphically from “User Manager” From a shell prompt

12 Create a user account graphically Click the Start Here icon on the desktop. In the new window that opens, click the System Settings icon, and then click the Users & Groups icon. You can also select Main Menu => System Settings => Users & Groups from the panel. You can also start the User Manager by typing redhat-config-users at a shell prompt. If you are not logged in as root, you will be prompted for your root password. The ‘User Manager’ window appears

13 Create a user account graphically (cont.) To add a new user, click the Add User button. Type the username and full name for the new user in the appropriate fields Type the user's password in the Password and Confirm Password fields. The password must be at least six characters. Select a login shell. If you are not sure which shell to select, accept the default value of /bin/bash. The default home directory is /home/username. You can change the home directory that is created for the user, or you can choose not to create the home directory by unselecting Create home directory. If you select to create the home directory, default configuration files are copied from the /etc/skel directory into the new home directory. To specify a user ID for the user, select Specify user ID manually. If the option is not selected, the next available user ID starting with number 500 will be assigned to the new user. Red Hat Linux reserves user IDs below 500 for system users. Click OK to create the user.

14 Create a user from shell prompt To create a user account from a shell prompt: 1.Open a shell prompt. 2.If you are not logged in as root, type the command ‘su –’ and enter the root password. 3.Type useradd followed by a space and the username for the new account you are creating at the command line (for example, useradd jsmith). Press [Enter]. Often, usernames are variations on the user's name, such as gpapam for George Papamarkos, but the final choice is yours. 4.Type passwd followed by a space and the username again (for example, passwd jsmith). 5.At the New password: prompt enter a password for the new user and press [Enter]. 6.At the Retype new password: prompt, enter the same password to confirm your selection. 7.For more options on user creation see man useradd

15 Modifying User Properties To view the properties of an existing user, click on the Users tab, select the user from the user list, and click Properties from the button menu The User Properties window is divided into multiple tabbed pages: –User Data — Shows the basic user information configured when you added the user. Use this tab to change the user's full name, password, home directory, or login shell. –Account Info — Select Enable account expiration if you want the account to expire on a certain date. Enter the date in the provided fields. Select User account is locked to lock the user account so that the user cannot log in to the system. –Password Info — This tab shows the date that the user's password last changed. To force the user to change passwords after a certain number of days, select Enable password expiration. The number of days before the user's password password, the number of days before the user is warned to change passwords, and days before the account becomes inactive can also be changed. –Groups — Select the groups that you want the user to be a member of and the user's primary group. Command ‘usermod’ gives the same functionality from command line

16 User Groups In Linux/Unix systems users are organised in groups A group is a smart way to manage authentication setting in Linux Each group defines an access policy over an certain system resource (e.g. cdrom, audio devices etc.) Each user belongs to a set of groups

17 Adding a New Group graphically In the ‘User & Groups’ application To add a new user group, click the Add Group button Type the name of the new group to create. To specify a group ID for the new group, select Specify group ID manually and select the GID. Red Hat Linux reserves group IDs lower than 500 for system groups. Click OK to create the group. The new group will appear in the group list.

18 Adding a Group from the shell prompt To add a group to the system, use the command groupadd groupadd The command line options for groupadd are: Exit with an error if the group already exists. (The group is not altered.) If -g and -f are specified, but the group already exists, the -g option is ignored. -f Create a system group with a GID less than 500. -r Group ID for the group, which must be unique and greater than 499. -g gid DescriptionOption

19 Modifying Group Properties To view the properties of an existing group, select the group from the group list and click Properties from the button menu The Group Users tab displays which users are members of the group. Select additional users to be added to the group, or unselect users to be removed from the group Click OK or Apply to modify the users in the group.

20 Getting system information – System Processes To get information about the processes running on your system we can use ‘ps’ command from the shell prompt. The ‘ps ax’ (‘ax’ are the parameters passed) command displays a list of current system processes, including processes owned by other users. To display the owner of the processes along with the processes use the command ‘ps aux’. The ps output can be long. To prevent it from scrolling off the screen, you can pipe it through ‘less’ command: –ps aux | less You can use the ps command in combination with the ‘grep’ command to see if a process is running. E.g. to see if ‘mozilla’ is running type: –ps ax | grep emacs

21 Getting system information – System Processes (2) The ‘top’ command displays currently running processes and important information about them including their memory and CPU usage. In contrast to ‘ps’ command ‘top’ is interactive and real-time To exit top, press the [q] key.

22 Getting system information – System Processes (3) In GNOME and KDE you can use a Graphic System Monitor as well. In GNOME for example select Main Menu Button (on the Panel) => System Tools => System Monitor or type gnome-system- monitor at a shell prompt from within the X Window System to get the GNOME System Monitor tool GNOME System Monitor gives you almost all the facilities provided by ‘top’ command but graphically You can end a process, search a process by name etc.

23 Getting System Information – Memory Usage The ‘free’ command displays the total amount of physical memory and swap space for the system as well as the amount of memory that is used, free, shared, in kernel buffers, and cached. The command ‘free –m’ shows the same information in megabytes, which are easier to read. This information can also be taken by getting the contents of ‘meminfo’ file in ‘proc’ directory. To do so type: –cat /proc/meminfo Graphically you can still use GNOME System Monitor and select the ‘System Monitor’ tab

24 Getting System Information – Monitor Disks The ‘df’ command reports the system's disk space usage. By default, this utility shows the partition size in 1 kilobyte blocks and the amount of used and available disk space in kilobytes. To view the information in megabytes and gigabytes, use the command ‘df –h’. The -h argument stands for human-readable format. For more see the appropriate manual page

25 That’s all folks ! Thanks a lot for your attention !!

Download ppt "Linux Installation and Administration Lesson 2 Tutor: George Papamarkos."

Similar presentations

Ads by Google