320 likes | 625 Views
RH030 Linux Computing Essentials. Understanding the Basic Linux Structure. Objectives. Structure of the Linux OS Use of shells and their relationship to C.L Use of the system directories FSH = hierarchical filesystem structure FSH = structure of the directory tree structure
E N D
RH030 Linux Computing Essentials Understanding the Basic Linux Structure
Objectives • Structure of the Linux OS • Use of shells and their relationship to C.L • Use of the system directories • FSH = hierarchical filesystem structure • FSH = structure of the directory tree structure • Navigation using absolute / relative pathnames • Structure of the command line. • Basic navigation commands Linux+ Guide to Linux Certification, 2e
Linux / UNIX - Interfaces User Applications User mode Desktop– GNOME, KDE XWindows – intel = xfree86 SHELL – Command line Interface Standard Utility Programs - Kernel - Standard library Programs Kernel mode Hardware Linux+ Guide to Linux Certification, 2e
Applications XWindows shells Kernel Hardware Main Elements of Linux/Unix OS • Kernelmanages memory manages system resources manages processes schedules programs manages file system - data/file access and storage - enforces security mechanismsperforms all hardware access Linux+ Guide to Linux Certification, 2e
Applications XWindows shells Kernel Hardware Main Elements of Linux/Unix OS • ShellThere are many different shell programs: - Bourne (sh), Korn (ksh), C (csh) Bourne Again (bash) It acts as the interface between the user and the kernel presents each user with a command promptinterprets commands typed by a userexecutes user commandssupports a custom environment for each user • Utilitiesfile management -rm, cat, ls, rmdir, mkdiruser management - passwd, chmod, chgrpprocess management - kill, pscompression – tar, cpio, gzipadministrative – useradd, groupadd, who, su Linux+ Guide to Linux Certification, 2e
Difference between the Windows & Linux Directory Structure Figure 4-1: The Windows filesystem structure Figure 4-2: The Linux filesystem structure Linux+ Guide to Linux Certification, 2e
Linux FSH = Directory Tree Structure Linux+ Guide to Linux Certification, 2e
Under the \ are the System Directories Table 5-1: Linux directories defined by FHS Linux+ Guide to Linux Certification, 2e
2 Types of Unix/Linux users Superuser # = There is only one system administrator account, created during installation They always log onto the system as root. Regular User $= These are created by the superuser • All accounts have a home directory. • The hierarchical filesystem starts from the top of the tree “ /” which is called the “root” directory . • Immediately under which are the system directories. • 2 of these are: • /root directory which is the home directory for the superuser /home directory which contains a separate home directory for each of the regular user accounts.
You have to Login to Linux • Multiuser environments require you to have a users account. • You can log in thru command-line interface or a GUI interface. • The Command-line interface is always available. • You need to install the GUI interface during installation to use it. • Login will also require a password. Linux+ Guide to Linux Certification, 2e
Even after you login Linux still offers the user many choices for their Interfaces 1. Command-line using shell • There are multiple CL screens available for the use of the user. • You access them by using the Crtl+Alt+F key combinations to change to separate terminal screens. 2. Graphical Interface using Xwindows • You can start a GUI interface on any of these multiple screens . • You can access a GUI interface with the Crtl+Alt+F7 key combination • You can use the Crtl+Alt+Bkspace key to shutdown the GUI • You can have access to both GUI & CL interfaces. • Load the GUI by default and use terminal program for CL • Or load CL by default and switch to a GUI by typing startx • This will start a GUI environment on top of the shell Linux+ Guide to Linux Certification, 2e
Linux has a wonderful GUI environment. • But we will not spend much time on the GUI. • Because anyone can easily learn to use a GUI. • CL is much harder. • And to be a Linux system administrators you use command-line. • The Linux certifications all focus on command-line. Linux+ Guide to Linux Certification, 2e
/ FSH = Directory Tree Structure • FSH is just an inverted tree of containers & files • parent directories & child directories (subdirectories) • top the tree is always designated as a forward slash (/) • this is called the root directory Linux+ Guide to Linux Certification, 2e
FSH uses pathnames to access items • A pathname specifies the location of a file on disk. • Every file and directory on a system has a pathname. • The ‘/’ separates file and directory names in a pathname. • What is the pathname of the file pointed to by the red arrows? Linux+ Guide to Linux Certification, 2e
Pathname Components • Directory paths are important you navigate within the system using them. • Slashes within the pathname are delimiters between object names • Object names can be either sub-directories or files Linux+ Guide to Linux Certification, 2e
2 Types of Pathnames • Absolute Pathname • Specifies the location of a file in relation to the entire file system. • Starts with the root (‘/’) directory. • Use the pwd (“Print Working Directory”) command to get the absolute pathname to the current directory. • Relative Pathname • Does not start with ‘/’. • Specifies the location of a file in relation to the current directory. • Can get to a file or directory in the current directory by simply using its name. Linux+ Guide to Linux Certification, 2e
Changing Location in the FSH • You use the cd(“Change Directory”) command to move to a different directory in the file system. • Accepts either absolute or relative pathnames. • Relative pathname symbols • Are used for navigational shortcuts /timesavers. • . (dot) The current directory. • .. (dot dot) The parent directory. • ~ Refers to your home directory Linux+ Guide to Linux Certification, 2e
Absolute verse Relative pathnames • Absolute pathname: always start from the top with a / cd /home/sheila/class-files/dir1 • Relative pathname:never starts with “/” cd class-files/dir1 cd ./class-files/dir1 cd ~/class-files/dir1 • Relative pathnames can also move up: • using a “..” per layer cd ../class-files/dir1 cd ../../../ class-files/dir1
Examples of Absolute Pathnames Absolute pathname to the user2 directory = /home/user2 Absolute pathname to the dir1 directory = /home/user2/dir1 Absolute pathname to the coffees directory = /home/user2/dir1/coffees Linux+ Guide to Linux Certification, 2e
Examples of Relative Pathnames If your current directory is /home: Relative pathname to the user2 directory = user2 Relative pathname to the dir1 directory = user2/dir1 Relative pathname to the coffees directory = user2/dir1/coffees Linux+ Guide to Linux Certification, 2e
Basic Structure of Command Syntax • Before you can use Unix commands effectively, you need to understand their general syntax. • $ command [option(s)][argument(s)] Shell Prompt Command Modifiers Executable Name Command Targets Linux+ Guide to Linux Certification, 2e
Example of command syntax <command> <options> <arguments> • First immediately after the prompt is the command $ ls • Commands are case sensitive and mostly in lowercase • A command may or may not have options • Options are used to modify the output. $ ls - l • A command may or may not have arguments • Arguments are usually files or directories $ ls - al /etc
Example of Basic Shell Commands • Linux Commands are case sensitive DOS LINUX PURPOSE cd cd change directory dir ls list the directory contents copy cp copy move mv move del rm delete/remove deltree rm -r remove directory + contents type cat display a file copy con cat > create a file md mkdir create a new directory rm rmdir delete a directory
Command Line Syntax • refers to the structure of the command • specifies allowable options and arguments Linux+ Guide to Linux Certification, 2e
Command Line Examples Linux+ Guide to Linux Certification, 2e
Command-Line Syntax Rules Linux+ Guide to Linux Certification, 2e
Viewing the contents of Directories • lscommand: • ls on it’s own display’s a brief listing of the contents of the directory – listing the items names only • Most commonly used options: • ls – l : detailed display or long listing of items. ll command: Is the default Alias for ls -l • ls – a : displays hidden files Linux+ Guide to Linux Certification, 2e
Viewing the contents of files • catcommand: cat dante displays dante in the cwd cat ./dante displays dante in the cwd cat ~/dante displays dante in your home directory • It can actually be used in many ways. • Which we will see later. Linux+ Guide to Linux Certification, 2e
Some really basic commands • Where am I in the FSH $ pwd • Moving around the FSH $ cd /etc $ cd thesis/fig $ cd .. • Displaying the contents of directories. $ ls $ ls -a $ ls -l $ ls -al $ ls -ald
Do you have a Redhat Academy Account yet? • Because from now on - you will need one! • Lets do todays’s exercises