0% found this document useful (0 votes)
13 views

CPNT217 - 15. Basic Linux Administration

Linux is an open-source operating system that is cost-effective, highly customizable, and flexible for various installations. Developed by Linus Torvalds in 1991, it has a hierarchical file system and supports multiple shells for user interaction. The terminal serves as an efficient command interface for executing system commands and managing files.

Uploaded by

Pragunya Wadhwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

CPNT217 - 15. Basic Linux Administration

Linux is an open-source operating system that is cost-effective, highly customizable, and flexible for various installations. Developed by Linus Torvalds in 1991, it has a hierarchical file system and supports multiple shells for user interaction. The terminal serves as an efficient command interface for executing system commands and managing files.

Uploaded by

Pragunya Wadhwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

CPNT217 – Introduction

to Network Systems
Module 5: Basic Linux Administration
Linux
Why use Linux?

• The largest factor in a decision to use Linux is generally


the cost. Because the Linux kernel is open-source, most
Linux distributions (Distros) are free to use.
• Linux is incredibly customizable, to the point where
users can create their own distro if they wish. Even
using an established distro, a user can still configure
options in a wide variety of combinations.
• Linux is very flexible, able to be installed with/without a
graphical user interface (GUI), as a client machine or
server, etc.
How did Linux come about?

Linux was developed by Linus Torvalds in


1991. He was a student at the university of
Helsinki who wanted to build an open-
source clone of an older operating system
named UNIX. He built the kernel and
released it to the public. The Linux kernel
By Lf Asia - Imported from 500px (archived version) by the Archive Team. (detail page),
CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=108824226

has been used since then to create


distributions (Covered by the umbrella term The Linux kernel is also the base of
the Android mobile operating
‘Linux’) such as Debian, Fedora, Red Hat, system.
Ubuntu, and others.
Firefox Browser and
Thunderbird Mail Apps Power and utilities

Files (Folder Structure)

Ubuntu Software (Download Apps)

Help and Support

Recycle Bin

The Ubuntu Desktop


Installed Applications
Folder Structure

• System root (/): The very base of the Filesystem


Hierarchical Standard (FHS) Everything is contained inside
the root directory. (Don’t confuse the root directory with the
root folder. The folder contains files for the root user.)
• bin (/bin): Contains essential user binaries or programs
which are used when the system is running in single-user
mode. These are important system programs and utilities.
(Applications that are user-specific can be found in /usr/bin.)
• dev (/dev): Contains files that represent devices in the
system. For example, /dev/sda represents the first SATA
recognized by the system.
• /cdrom, /mnt, /media:
Allow removable
devices/media to be
attached to the system.
• /opt: Storage for optional
software packages that
don’t always fit the FHS.
• /home: Every user will have
a folder in the home folder.
This is where their own data
and user-specific
configuration data will be
stored.

(There are many more folders, such as /usr, which is read-only and contains applications and files for users (as opposed to those
used by the system), and /var, which contains log files and data written by applications from the /usr folder.)
The root filesystem

• /bin - contains the binaries or


executables for system stuff
• /boot - the kernel and the bootstrap
• /dev - devices drivers
• /etc - configuration files for system
startup
• /mnt - mount points
• /sbin – essential system binaries
• /usr - files specific to the user
• /usr/sbin contains utilities for the usr
• /home - the users main storage use area
Files

• In Linux, a file is the basic component for data storage


• Linux considers everything it interacts with as a file,
even attached devices such as monitors and printers
• The file system is a logical tree system like we saw in
DOS
• The root is represented by a forward slash - /
•Applications:

•Shortcuts for applications


installed on the system. Also
allows access to Settings and
Utilities.
Utilities

• Controls for:
• Networking
• Disk Management
• Stored Passwords
• Backups
and other things.
Utilities

• Disk Management • Network Management

• Disk Management • Network Management


Settings
Gives general information regarding the operating
system and hardware.
Ubuntu
Terminal
•The Terminal is
Ubuntu’s command-line
interface, allowing
users to issue
commands to effect
changes in the
operating system.
The Command Line
The Shell

• Shells provide the interface between users and the


kernel
• Command interpreter – just like Windows CLI
• Use keyboard shortcuts to enter long commands quickly
• Control multiple programs
• Define variables to make shell environment easier to use or to
provide information that other programs can access when
needed
The Shell
Bourne Again Shell -bash

• Prompt - $ for normal users and # for root


• Configuration files
• etc/profile - global environment settings
• -/.profile - users personal file (hidden file)
• the users file will always override the global configuration file
• Similar shells
• sh - Bourne shell
• ksh - Korn shell
Shells

• You choose a shell when the system administrator sets


up your user account
• Most users choose the Bash shell, although you can
choose any of them
• However, you can switch from one shell to another by
typing the shell’s name (such as tcsch, bash, or zsh) on
your command line
• You can have multiple shells open simultaneously
Logon/Logoff

• After you connect to a UNIX-based system, you must log on by entering


your username and password
• On a standalone PC that has Linux installed
• Through a telnet/ssh connection to a remote computer
• As a client on a UNIX client/server network
• root – the built in user with universal powers (super user)
• Logging Out
• Ctrl D
• logoff
• through gui – Menu button, then logout
• Shutdown
• shutdown command
• halt command
• through gui – System menu in login screen, then Halt
• Commands can be broken down
into several different categories,
depending on their purpose:
• Navigation commands;
Command • Search commands;
types and • File Management commands;
functions • User Management commands;
• File Permission commands;
• Package Management commands;
• Network Management commands;
and others
UNIX Commands

• Entered at the shell prompt


• Case sensitive – most commands are lower case
• Two types
• User level
• System administration
• Syntax
• command_name [-options] [arguments]
• type ‘Date’ <enter>
• type ‘date’ <enter>
• type ‘date -u’ <enter>
• Most shells keep a list of your recently used commands (buffer) and
allow you to recall a command without retyping it (like the command
line in Windows) using the up arrow key.
Getting Help

• help – gives you a list of the commands which you may


get a help listing for
• help {command}
• whatis – may give you information about a command
• whatis {command}
• man pages – detailed information about commands and
utilities
• man utility  man {command}
• pg down to move through page
• q to quit man page
Passwords

• It is a good idea, particularly on shared systems, VM’s,


or imaged machines to change your password, and that
of the root user
• passwd – allows you to reset your own password, or
other’s password if you are root
Navigation

• To navigate the UNIX directory structure, use the cd


(change directory) command
• Syntax  cd {directory}
• cd .. – sends you back one directory
• cd ~ - returns the user to their home directory
• cd / - returns you to the root directory
• The spaces are important!
Paths

• Absolute path or Relative path


• An absolute path begins at the root level and lists all
subdirectories to the destination file
• cd /home/labs/lab2 – an absolute path from the root directory
to the lab2 directory
• A relative path is from where you are currently
• cd ../lab3 – the lab3 directory is up one directory and down
into the lab3
Listing Directory Contents

• ls[1] (list) – some versions of UNIX will respond to dir as


well
• ls –l (long listing) (also ll)
• ls –l /etc (List contents of an absolute path)
• ls –a (all)
• Hidden files start with .

[1] ls – Lower case L


User Account Management commands

• Used to modify user accounts and groups from the command


line.
• su – Switch user, used to change which user account is
being used.
• sudo – Superuser do, allows the use of elevated or
administrator commands.
• useradd, usermod, userdel – Used to add, modify or delete
user accounts.
• groupadd, groupmod, groupdel – Used to add, modify or
delete user groups.
File Permissions commands
File permissions are indicated by 3 characters, used to represent
read, write, and execute permissions. (r, w, x) Each group of
characters represents the permissions allowed to a specific user,
a group of users, or the global group.
1. User/owner permissions – read, write, execute
Permissions are set or modified using Octal values, from 0-7 (3 2. Group permissions – read, write, execute
bits). The read permission holds a value of 4, the write 3. Global permissions – read, write, execute
permission a value of 2, and the execute permission a value of
1. Thus, a user with the read and execute permissions, but 1 2 3
without the write permission, would receive a value of 5.

We use the chmod command to modify the permissions on a


file, as follows: chmod 554 test.txt This assigns the approved User/owner Group
user and group the read and execute permissions, while setting
the global value to read only.

Other commands in this category include chown and chgrp, Indicates directory
which change the owner or group entitled to the file
respectively.
Unix File Listing
-rw-r--r-- 1 johnston staff 536 Sep 16 20:35 .myfile

d directory Links Last


group
- plain file Modified File
b block-type special file Name
c character-type special file
Size
l symbolic link
s socket
in
p named pipe
Bytes
Owner
r read
w write
x execute
- none
(user | group | other)
File Naming Convention

• All file names are case sensitive


• Filenames can be up to 256 characters
• Filenames can contain periods, numbers and
punctuation
• Filenames may not contain slashes
• File extensions are not necessary but are used
the same as DOS except there are no .exe
or .com files
Directories and Files

• Create a directory with mkdir (make directory)


• Delete empty directories by using the rmdir (remove
directory) command
• The rm –r will remove directories recursively (all
contents, all subdirectories and all sub-subdirectories
etc – BE CAREFUL)
• Delete files with rm (remove) command
• Use rm -i (interactive) option to have UNIX warn you
before deleting the file
Copying and Moving Files

• cp [-options] {source} {destination}


• cp –i warn if overwrite a destination file
• cp file.txt /labs/lab2/file.txt
• cp –i file.txt /labs/lab2/file.txt
• cp ../lab3/file.txt
• mv [-options] {source} {destination}
• mv file.txt /lab/lab2/file.txt
• mv –i file.txt /laabs/lab2/file.txt
• mv ../lab3/file.txt
• Rename (Some distros use this, others use mv)
• rename file.txt newfile.txt
Finding Files

• The find command searches for files by name


• find {pathname} - name {filename}
• The find command prohibits you from searching where
you do not have system-level permissions
Symbolic Links

Names Copy of
(cp) Copy command Names
and Names
and
Phone and
Phone
Numbers Phone
Numbers
Numbers

Names Link to
(ln)[1] Link command Names
and Names
and
Phone and
Phone
Numbers Phone
Numbers
Numbers

If you change the linked version, you actually change


the original.

[1] ln – lower-case L
Symbolic Links

• Used when the same data


/Doug/numbers.txt
must be accessed from two
locations.
Symbolic Link
• ln[1] –s {existingfile}
{symbolicfile}
/documents/Numbers.txt
Names
and
Phone
/Connie/numbers.txt Numbers
Symbolic Link

[1] ln – lower-case L
File Viewing

• cat – prints the contents of a file to the console


• more – allows you to view files a page at a time
• more filename
• q to quit the more viewer
• less – another file viewer, like more except lets you move back and forth in
file.
• head – allows you to view the first few lines of a file
• head filename
• default is 10 lines
• head –n 5 filename
• tail – allows you to view the last few lines of a file
• tail filename
• default is 10 lines
• tail –n 5 filename
Redirection and Piping

• Redirection
• Normally the output of a command goes to the screen
• Redirection allows you to send it somewhere else like a file
• ls > file.txt
• Pipes
• Allow you to take the output from one command and send it to
the input of another command
• firstcommand | secondcommand
• ls | more
Additional File Commands

• wc – counts the number of lines (-l option), words (-w option),


and characters (-c option)
• wc –l {filename}
• touch – creates an empty file or allows you to update the
date and time of a file
• touch {filename}
• If file does not exist it is created
• If file does exist its time and date are updated to the current system date and
time
• paste – combines files line by line
• paste filename1 filename2 (output goes to screen)
• paste filename1 filename2 > filename3 (output goes to new file)
Working with processes

• ps – displays a snapshot of process information


• ps
• ps -a
• ps -aux
• ps -A
• top – displays process information in real time
• Use the ps command to find the process id
• type ‘kill pid’ = like canceling
• type ‘kill -1 pid’ = hanging up
• type ‘kill -9 pid’ = stop dead, may leave child processes
• Package Management • Network Management
commands commands
• Commands used to work • Used to inspect or modify the
with the package manager network configuration applied
to interfaces on this system.
to check/download • ip – Used to show or change
updates, install software. addressing configuration.
• apt or yum – Depending on • netplan – modifies the
the distribution root (Debian networking configuration files
or Red Hat) this command is directly.
used to indicate an operation • dig – Used to troubleshoot DNS
with the package manager. and name resolution methods
• Common commands are • dhclient – Allows us to
update, upgrade, and install release/renew DHCP adresses
Summary

• Linux uses an open-source kernel, which allows users to


customize or create new distributions based on their
needs or preferences.
• Linux can use many different types of shells, such as
Graphical User Interfaces and Command Line Interfaces,
for users to interact with the operating system.
• The terminal in Linux is typically the most efficient
method of inputting and executing commands, provided
the user understands the commands and their uses.

You might also like