SlideShare une entreprise Scribd logo
1  sur  23
Junior Level Linux Certification
Exam Objectives
Key Knowledge Areas
Use single shell commands and one line command sequences to perform basic tasks on the
command line.
Use and modify the shell environment including defining, referencing and exporting
environment variables.
Use and edit command history.
Invoke commands inside and outside the defined path.
Objective 3: GNU and Unix Commands
Work on the command line Weight: 4
Terms and Utilities
. Bash echo
env exec Export
pwd set unset
man uname history
2
GNU and Unix Commands
The shell allows users to enter commands and then interprets these commands
into instructions for the Linux operating system.
Linux allows you to use a number of different shells; however, the default shell installed with
Linux is the bash shell.
default shell is specified in /etc/passwd file and can be changed there on a per user basis.
Shells
3
To change to a different shell, you simply type the full path along with the command name of
the new shell. Ex. /bin/csh
To return to the default login shell, type exit or press CTRL-D.
The default login shell is contained in the environment variable SHELL.
Each shell has corresponding resource configuration file - rc file, located in /etc directory
It contains global settings for the shell. For the bash shell the file is /etc/bashrc.
To know which default shell is currently configured, type: echo $SHELL
GNU and Unix Commands
The available shells and paths are listed in /etc/shells
Shells
4
Shell Explanation
/bin/bash Bourne-Again Shell that is compatible with the sh shell, which includes features of both the
Korn and C shells. This may be a link to the /bin/bash2 file on some distributions.
/bin/sh The Bourne Shell. On many systems this file is linked to /bin/bash.
/bin/ash A System V version of the sh shell.
/bin/bsh This file is linked to /bin/ash.
/bin/bash2 Bourne-Again Shell version 2.
/bin/csh The Berkeley UNIX C shell.
/bin/tcsh An enhanced version of the Berkeley UNIX C shell.
chsh command is used to change the default shell for the user
Options Alternate Function
-s --shells Specifies the default login shell for this user.
-l --list Lists the shells specified in the /etc/shells file.
-u --help Displays the options for the chsh command.
-v --version Displays version information for the shell.
GNU and Unix Commands
Syntax:
$ command options arguments
Using the Command Line
5
$ ls # simple commandEx:
$ ls –F # command with options
$ ls -F /etc # execute command on other directory
$ ls -F /etc ; ls -F /usr # first command will complete before next command is started
$ ls -F /etc  # ignore Enter key and treat all commands as though they are on the same cmdline.
ls -F /usr
GNU and Unix Commands
Using the Command Line
6
Command completion:
bash shell includes a feature called command completion.
This enables to type first few letters of the command at the prompt, hit the Tab key, and have the system
complete the command.
$ dm <press tab key>Ex:
$ dmesg
• If there is more than one possible match, the system will simply beep.
• Pressing Tab key again will display all possible command matches.
• Pressing Esc twice performs same action as pressing the Tab key.
GNU and Unix Commands
Using the Command Line
7
Editing shell commands with the Readline Library:
Key Combination Function
Ctrl-b Move back one character.
Ctrl-f Move forward one character.
Del Delete the character to the left of the cursor.
Ctrl-d Delete the character underneath the cursor.
Ctrl-a Move to the start of the line.
Ctrl-e Move to the end of the line.
Esc-f Move forward a word.
Esc-b Move backward a word.
Ctrl-l Clear the screen, reprinting the current line at the top.
Ctrl-k Kill (delete) the text from the current cursor position to the end of the line.
Esc-d Kill from the cursor to the end of the current word, or if between words, to the end of the next word.
Esc-Del Kill from the cursor the start of the previous word, or if between words, to the start of the previous word.
Ctrl-w Kill from the cursor to the previous white space.
This differs from Esc-Del because the boundaries separating words differ.
•Editor can be configured globally using /etc/inputrc file for global changes.
•To make changes for specific user edit .inputrc file located in user’s home directory.
This file can be used to change key mappings for Readline Library editor, and map keys to commonly used commands.
•To view keyboard bindings type the command: bind -v
GNU and Unix Commands
Using the Command Line
8
History file
history file contains list of commands issued at command prompt.
Number of commands stored - Is specified by HISTSIZE environment variable in:
/etc/profile or ~/.profile file - Default setting is 1,000 entries.
The command history displays all entries in the history file, which is ~/.bash_history.
HISTCMD
variable is used to provide history index number of command currently being run.
HISTFILE
variable specifies file used to contain the cmd history – default /home/user/.bash_history.
HISTFILESIZE
variable specifies maximum number of lines contained in the HISTFILE.
GNU and Unix Commands
Using the Command Line
9
fc
provides another option for editing commands in history file before running them.
fc utility opens the command into default editor, to edit and save it before rerunning the command.
fc utility allows to specify number of history events to edit, which enables to edit a range of cmds at once.
# fc –l 1020 1025
1020 cd /etc
1021 ls -al
1022 vi services
1023 vi hosts
1024 man ls
1025 ls -al s*
Ex: Example uses fc utility to list the history events1020-1025.
GNU and Unix Commands
Environment variables
10
Command substitution $(...) and `...`
Some commands say interesting things to include as parameters on other commands.
command substitution operators allows to include output of a command in another command.
foo:~ $ whoami
Gerald
foo:~ $ grep gerald /etc/passwd
gerald:x:500:500:G Smith:/home/gerald:/bin/bash
It's much easier like using substitution:
foo:~ $ grep `whoami` /etc/passwd
gerald:x:500:500: G Smith:/home/gerald:/bin/bash
foo:~ $ grep $( whoami ) /etc/passwd
gerald:x:500:500: G Smith:/home/gerald:/bin/bash
Ex: # echo `pwd`
Ex:
GNU and Unix Commands
Environment variables
11
Prompt
The shell prompt can be configured by the user to display a variety of information.
[godmode@zeus godmode]$ _Ex:
Godmode:login name; zeus: name of computer; 2nd
godmode: current working directory; _: represents cursor.
prompt is set by environmental variable called PS1.
To display the current settings use command echo $PS1
System-wide setting of prompt (for all users) is in file /etc/bashrc
[godmode@zeus godmode]$ cat /etc/bashrcEx:
To customize prompt, edit file /etc/bashrc (as root) and insert almost any text inside the quotes.
GNU and Unix Commands
Environment variables
12
Prompt
Settings Used To Configure the Prompt
Setting Meaning
u User name of the current user.
h The name of the computer running the shell (hostname).
W The base of the name of the current working directory.
w The full name of the current working directory.
$ Displays “$” for normal users and “#” for the root.
! History number of the current command.
# Number of the current command.
d Current date.
t Current time.
s Name of the shell.
n New line.
 Backslash.
[ Begins a sequence of nonprintable characters.
] Ends a sequence of nonprintable characters.
nnn The ASCII character corresponding to the octal number nnn.
$(date) Output from the date command (or any other command for that matter).
GNU and Unix Commands
Environment variables
13
$PATH
When you enter a command, bash searches for executable program in a number of directories.
The places bash searches are specified in the PATH environment variable.
foo:~ $ echo $PATH
/home/user/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin
Ex:
One of places that bash does not search by default is the current directory – usually.
Some distributions do include the current directory in the path (spot the difference).
linux:~ > echo $PATH
/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/home/joe/bin:
Ex:
Because of PATH environment variable, you can enter cmds in any working directory.
you can use the ls cmd even when you are not in the /bin directory which contains the ls program.
linux:/usr/bin $ cd /bin
linux:/bin $ ls -la ls
-rwxr-xr-x 1 root root 90811 Apr 20 16:32 ls
linux:/bin $ cd /usr/bin
linux:/usr/bin $ ls -la ls
/bin/ls: ls: No such file or directory
Ex:
GNU and Unix Commands
Environment variables
14
The shell environment contains values called environment variables which can be displayed
and changed.
To change value of an environment variable, use the syntax: VARIABLENAME='value'
commands related to setting environment variables:
foo:~ $ set | less
foo:~ $ echo PATH
foo:~ $ echo $PATH
foo:~ $ echo HOME
foo:~ $ echo $HOME
foo:~ $ echo $HOSTNAME
foo:~ $ echo $PS1
foo:~ $ PS1="# "
foo:~ $ PS1='u: w $ '
foo:~ $ env | less # search for PS1 by typing /PS1, Enter...
foo:~ $ HOME=/var
foo:~ $ cd
foo:~ $ pwd
foo:~ $ HOME=~
Ex:
GNU and Unix Commands
Environment variables
15
command env displays list of all the exported environment variables.
These are the variables that are passed from shell to apps when the applications are executed
foo:~ $ env | head
KDE_MULTIHEAD=false
SSH_AGENT_PID=511
HOSTNAME=foo.ledge.co.za
TERM=xterm
SHELL=/bin/bash
XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched
HISTSIZE=1000
GTK_RC_FILES=/etc/gtk/gtkrc:/home/joe/.gtkrc
GS_LIB=/home/joe/.kde/share/fonts
QTDIR=/usr/lib/qt3-gcc3.4
Ex:
GNU and Unix Commands
Environment variables
16
The behaviour of many commands can be customised by setting (and exporting) shell
variables as listed on the man pages of the application.
foo:~ $ echo PRINTER value is $PRINTER
PRINTER value is
foo:~ $ lpq
lp0 is ready
no entries
foo:~ $ PRINTER=lp1
foo:~ $ export PRINTER
foo:~ $ lpq
lp1 is not ready
no entries
Ex: lpq command shows print queue for the current printer.
current printer is set using the PRINTER environment variable.
GNU and Unix Commands
Environment variables
17
To remove a variable, use the command unset.
foo:~ $ echo SSH_ASKPASS is $SSH_ASKPASS
SSH_ASKPASS is /usr/libexec/openssh/gnome-ssh-askpass
Ex:
foo:~ $ unset SSH_ASKPASS
foo:~ $ echo SSH_ASKPASS is $SSH_ASKPASS
SSH_ASKPASS is
foo:~ $
GNU and Unix Commands
Bash session
18
During a login session, bash does a number of special things:
• At beginning of session, file ~/.profile is run automatically.
Any special commands placed in this file are run whenever logged
• At end of the session, all commands entered are added to the file ~/.bash_history.
exec /usr/bin/pine # when pine exits, the session is over
If this is put in a user’s ~/.profile, that user will automatically run pine when logging.
contents of ~/.profile can include a exec command to replace the shell
Ex:
GNU and Unix Commands
Recursive commands
19
Recursion in terms of Linux commands refers to applying a command to a all the files in a
directory, and all the files in all the subdirectories (and subdirectories of subdirectories).
$ find /etc -type f -exec cat {} ; # find with find, then cat each one
Ex:
Some commands (ls, chown, chmod, cp, rm, grep) support switches – R or – r .
commands without recursive mode, combine the cmd with find to achieve your results.
find ... Exec can execute a specific command each time a file is found:
$ cat `find -type f /etc` # cat whatever find says
$ find /etc -type f | xargs cat # run cat with parameters from find
The output of find can list file names on the command line:
Using parameter -type f to find ensures that we only consider regular files.
find can use other criteria to identify files - name, permissions, modification, date, etc.
GNU and Unix Commands
man pages
20
The primary (and traditional) source of documentation is the manual pages, which
can be accessed using command: man command or man section command
Manual pages are usually installed when you install a package, so if you do not have a package installed,
you probably won't have a manual page for it.
Manual pages have:
•A heading with the name of the command followed by its section number in parentheses
•The name of the command and any related commands that are described on the same man page
•A synopsis of the options and parameters applicable to the command
•A short description of the command
•Detailed information on each of the options
There might be other sections on usage, how to report bugs, author information, and a list of related commands. For
example, the man page for man tells us that related commands (and their manual sections) are: apropos(1), whatis(1),
less(1), groff(1), and man.conf(5).
GNU and Unix Commands
man pages
21
There are 8 common manual page sections:
1. User commands (env, ls, echo, mkdir, tty)
2. System calls or kernel functions (link, sethostname, mkdir)
3. Library routines (acosh, asctime, btree, locale, XML::Parser)
4. Device related information (isdn_audio, mouse, tty, zero)
5. File format descriptions (keymaps, motd, wvdial.conf)
6. Games (note that many games are now graphical and have graphical help outside the man page system)
7. Miscellaneous (arp, boot, regex, unix utf8)
8. System administration (debugfs, fdisk, fsck, mount, renice, rpm)
Other sections could include:
9.for Linux kernel documentation,
n. new documentation,
o. old documentation,
l. local documentation.
2 important commands related to man are whatis and apropos.
whatis - searches man pages for the name given and displays name info from appropriate manual pages.
apropos - does a keyword search of manual pages and lists ones containing the keyword.
commands
. The current directory
bash What you bash your commands into
echo echo
env Show environment variables
exec Run and don’t return
export Add a variable to the export list
man Manual pages
pwd Print working directory
set Show environment settings
unset Clear an environment variable
~/.bash_history The last n commands you typed
~/.profile What runs when you login interactively
Test commands for exam
22
GNU and Unix Commands
Fim de sessão
23

Contenu connexe

Tendances

Unix Commands
Unix CommandsUnix Commands
Unix CommandsDr.Ravi
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unixsouthees
 
Bash shell
Bash shellBash shell
Bash shellxylas121
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands Raghav Arora
 
Unix Command Line Productivity Tips
Unix Command Line Productivity TipsUnix Command Line Productivity Tips
Unix Command Line Productivity TipsKeith Bennett
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptroot_fibo
 
5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variablesGautam Raja
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scriptingAkshay Siwal
 
linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014Peter Martin
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 
Top 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsTop 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsYusuf Felly
 
101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4Acácio Oliveira
 

Tendances (20)

Unix Commands
Unix CommandsUnix Commands
Unix Commands
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Bash shell
Bash shellBash shell
Bash shell
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Unix practical file
Unix practical fileUnix practical file
Unix practical file
 
Unix
UnixUnix
Unix
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
 
Unix Command Line Productivity Tips
Unix Command Line Productivity TipsUnix Command Line Productivity Tips
Unix Command Line Productivity Tips
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
 
5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables
 
Os lab manual
Os lab manualOs lab manual
Os lab manual
 
Unix cmd
Unix cmdUnix cmd
Unix cmd
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scripting
 
linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Top 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsTop 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu Commands
 
basic-unix.pdf
basic-unix.pdfbasic-unix.pdf
basic-unix.pdf
 
Unix slideshare
Unix slideshareUnix slideshare
Unix slideshare
 
101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4
 

Similaire à 101 3.1 gnu and unix commands

Similaire à 101 3.1 gnu and unix commands (20)

UnixShells.ppt
UnixShells.pptUnixShells.ppt
UnixShells.ppt
 
Using Unix
Using UnixUsing Unix
Using Unix
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
Licão 09 variables and arrays v2
Licão 09 variables and arrays v2Licão 09 variables and arrays v2
Licão 09 variables and arrays v2
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdf
 
Directories description
Directories descriptionDirectories description
Directories description
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linux shell env
Linux shell envLinux shell env
Linux shell env
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.ppt
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02
 
60761 linux
60761 linux60761 linux
60761 linux
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
Linux
LinuxLinux
Linux
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 

Plus de Acácio Oliveira

Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxSecurity+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxSecurity+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxSecurity+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxSecurity+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxSecurity+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxSecurity+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxSecurity+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxSecurity+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxSecurity+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxSecurity+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxSecurity+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Acácio Oliveira
 
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxSecurity+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxSecurity+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Acácio Oliveira
 
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxSecurity+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxSecurity+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxSecurity+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxSecurity+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxSecurity+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxAcácio Oliveira
 

Plus de Acácio Oliveira (20)

Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxSecurity+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
 
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxSecurity+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
 
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxSecurity+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
 
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxSecurity+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
 
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxSecurity+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
 
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxSecurity+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
 
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxSecurity+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
 
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxSecurity+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
 
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxSecurity+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
 
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxSecurity+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
 
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxSecurity+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
 
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
 
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxSecurity+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
 
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxSecurity+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
 
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
 
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxSecurity+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
 
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxSecurity+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
 
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxSecurity+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
 
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxSecurity+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
 
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxSecurity+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
 

Dernier

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Dernier (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

101 3.1 gnu and unix commands

  • 1. Junior Level Linux Certification
  • 2. Exam Objectives Key Knowledge Areas Use single shell commands and one line command sequences to perform basic tasks on the command line. Use and modify the shell environment including defining, referencing and exporting environment variables. Use and edit command history. Invoke commands inside and outside the defined path. Objective 3: GNU and Unix Commands Work on the command line Weight: 4 Terms and Utilities . Bash echo env exec Export pwd set unset man uname history 2
  • 3. GNU and Unix Commands The shell allows users to enter commands and then interprets these commands into instructions for the Linux operating system. Linux allows you to use a number of different shells; however, the default shell installed with Linux is the bash shell. default shell is specified in /etc/passwd file and can be changed there on a per user basis. Shells 3 To change to a different shell, you simply type the full path along with the command name of the new shell. Ex. /bin/csh To return to the default login shell, type exit or press CTRL-D. The default login shell is contained in the environment variable SHELL. Each shell has corresponding resource configuration file - rc file, located in /etc directory It contains global settings for the shell. For the bash shell the file is /etc/bashrc. To know which default shell is currently configured, type: echo $SHELL
  • 4. GNU and Unix Commands The available shells and paths are listed in /etc/shells Shells 4 Shell Explanation /bin/bash Bourne-Again Shell that is compatible with the sh shell, which includes features of both the Korn and C shells. This may be a link to the /bin/bash2 file on some distributions. /bin/sh The Bourne Shell. On many systems this file is linked to /bin/bash. /bin/ash A System V version of the sh shell. /bin/bsh This file is linked to /bin/ash. /bin/bash2 Bourne-Again Shell version 2. /bin/csh The Berkeley UNIX C shell. /bin/tcsh An enhanced version of the Berkeley UNIX C shell. chsh command is used to change the default shell for the user Options Alternate Function -s --shells Specifies the default login shell for this user. -l --list Lists the shells specified in the /etc/shells file. -u --help Displays the options for the chsh command. -v --version Displays version information for the shell.
  • 5. GNU and Unix Commands Syntax: $ command options arguments Using the Command Line 5 $ ls # simple commandEx: $ ls –F # command with options $ ls -F /etc # execute command on other directory $ ls -F /etc ; ls -F /usr # first command will complete before next command is started $ ls -F /etc # ignore Enter key and treat all commands as though they are on the same cmdline. ls -F /usr
  • 6. GNU and Unix Commands Using the Command Line 6 Command completion: bash shell includes a feature called command completion. This enables to type first few letters of the command at the prompt, hit the Tab key, and have the system complete the command. $ dm <press tab key>Ex: $ dmesg • If there is more than one possible match, the system will simply beep. • Pressing Tab key again will display all possible command matches. • Pressing Esc twice performs same action as pressing the Tab key.
  • 7. GNU and Unix Commands Using the Command Line 7 Editing shell commands with the Readline Library: Key Combination Function Ctrl-b Move back one character. Ctrl-f Move forward one character. Del Delete the character to the left of the cursor. Ctrl-d Delete the character underneath the cursor. Ctrl-a Move to the start of the line. Ctrl-e Move to the end of the line. Esc-f Move forward a word. Esc-b Move backward a word. Ctrl-l Clear the screen, reprinting the current line at the top. Ctrl-k Kill (delete) the text from the current cursor position to the end of the line. Esc-d Kill from the cursor to the end of the current word, or if between words, to the end of the next word. Esc-Del Kill from the cursor the start of the previous word, or if between words, to the start of the previous word. Ctrl-w Kill from the cursor to the previous white space. This differs from Esc-Del because the boundaries separating words differ. •Editor can be configured globally using /etc/inputrc file for global changes. •To make changes for specific user edit .inputrc file located in user’s home directory. This file can be used to change key mappings for Readline Library editor, and map keys to commonly used commands. •To view keyboard bindings type the command: bind -v
  • 8. GNU and Unix Commands Using the Command Line 8 History file history file contains list of commands issued at command prompt. Number of commands stored - Is specified by HISTSIZE environment variable in: /etc/profile or ~/.profile file - Default setting is 1,000 entries. The command history displays all entries in the history file, which is ~/.bash_history. HISTCMD variable is used to provide history index number of command currently being run. HISTFILE variable specifies file used to contain the cmd history – default /home/user/.bash_history. HISTFILESIZE variable specifies maximum number of lines contained in the HISTFILE.
  • 9. GNU and Unix Commands Using the Command Line 9 fc provides another option for editing commands in history file before running them. fc utility opens the command into default editor, to edit and save it before rerunning the command. fc utility allows to specify number of history events to edit, which enables to edit a range of cmds at once. # fc –l 1020 1025 1020 cd /etc 1021 ls -al 1022 vi services 1023 vi hosts 1024 man ls 1025 ls -al s* Ex: Example uses fc utility to list the history events1020-1025.
  • 10. GNU and Unix Commands Environment variables 10 Command substitution $(...) and `...` Some commands say interesting things to include as parameters on other commands. command substitution operators allows to include output of a command in another command. foo:~ $ whoami Gerald foo:~ $ grep gerald /etc/passwd gerald:x:500:500:G Smith:/home/gerald:/bin/bash It's much easier like using substitution: foo:~ $ grep `whoami` /etc/passwd gerald:x:500:500: G Smith:/home/gerald:/bin/bash foo:~ $ grep $( whoami ) /etc/passwd gerald:x:500:500: G Smith:/home/gerald:/bin/bash Ex: # echo `pwd` Ex:
  • 11. GNU and Unix Commands Environment variables 11 Prompt The shell prompt can be configured by the user to display a variety of information. [godmode@zeus godmode]$ _Ex: Godmode:login name; zeus: name of computer; 2nd godmode: current working directory; _: represents cursor. prompt is set by environmental variable called PS1. To display the current settings use command echo $PS1 System-wide setting of prompt (for all users) is in file /etc/bashrc [godmode@zeus godmode]$ cat /etc/bashrcEx: To customize prompt, edit file /etc/bashrc (as root) and insert almost any text inside the quotes.
  • 12. GNU and Unix Commands Environment variables 12 Prompt Settings Used To Configure the Prompt Setting Meaning u User name of the current user. h The name of the computer running the shell (hostname). W The base of the name of the current working directory. w The full name of the current working directory. $ Displays “$” for normal users and “#” for the root. ! History number of the current command. # Number of the current command. d Current date. t Current time. s Name of the shell. n New line. Backslash. [ Begins a sequence of nonprintable characters. ] Ends a sequence of nonprintable characters. nnn The ASCII character corresponding to the octal number nnn. $(date) Output from the date command (or any other command for that matter).
  • 13. GNU and Unix Commands Environment variables 13 $PATH When you enter a command, bash searches for executable program in a number of directories. The places bash searches are specified in the PATH environment variable. foo:~ $ echo $PATH /home/user/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin Ex: One of places that bash does not search by default is the current directory – usually. Some distributions do include the current directory in the path (spot the difference). linux:~ > echo $PATH /bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/home/joe/bin: Ex: Because of PATH environment variable, you can enter cmds in any working directory. you can use the ls cmd even when you are not in the /bin directory which contains the ls program. linux:/usr/bin $ cd /bin linux:/bin $ ls -la ls -rwxr-xr-x 1 root root 90811 Apr 20 16:32 ls linux:/bin $ cd /usr/bin linux:/usr/bin $ ls -la ls /bin/ls: ls: No such file or directory Ex:
  • 14. GNU and Unix Commands Environment variables 14 The shell environment contains values called environment variables which can be displayed and changed. To change value of an environment variable, use the syntax: VARIABLENAME='value' commands related to setting environment variables: foo:~ $ set | less foo:~ $ echo PATH foo:~ $ echo $PATH foo:~ $ echo HOME foo:~ $ echo $HOME foo:~ $ echo $HOSTNAME foo:~ $ echo $PS1 foo:~ $ PS1="# " foo:~ $ PS1='u: w $ ' foo:~ $ env | less # search for PS1 by typing /PS1, Enter... foo:~ $ HOME=/var foo:~ $ cd foo:~ $ pwd foo:~ $ HOME=~ Ex:
  • 15. GNU and Unix Commands Environment variables 15 command env displays list of all the exported environment variables. These are the variables that are passed from shell to apps when the applications are executed foo:~ $ env | head KDE_MULTIHEAD=false SSH_AGENT_PID=511 HOSTNAME=foo.ledge.co.za TERM=xterm SHELL=/bin/bash XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched HISTSIZE=1000 GTK_RC_FILES=/etc/gtk/gtkrc:/home/joe/.gtkrc GS_LIB=/home/joe/.kde/share/fonts QTDIR=/usr/lib/qt3-gcc3.4 Ex:
  • 16. GNU and Unix Commands Environment variables 16 The behaviour of many commands can be customised by setting (and exporting) shell variables as listed on the man pages of the application. foo:~ $ echo PRINTER value is $PRINTER PRINTER value is foo:~ $ lpq lp0 is ready no entries foo:~ $ PRINTER=lp1 foo:~ $ export PRINTER foo:~ $ lpq lp1 is not ready no entries Ex: lpq command shows print queue for the current printer. current printer is set using the PRINTER environment variable.
  • 17. GNU and Unix Commands Environment variables 17 To remove a variable, use the command unset. foo:~ $ echo SSH_ASKPASS is $SSH_ASKPASS SSH_ASKPASS is /usr/libexec/openssh/gnome-ssh-askpass Ex: foo:~ $ unset SSH_ASKPASS foo:~ $ echo SSH_ASKPASS is $SSH_ASKPASS SSH_ASKPASS is foo:~ $
  • 18. GNU and Unix Commands Bash session 18 During a login session, bash does a number of special things: • At beginning of session, file ~/.profile is run automatically. Any special commands placed in this file are run whenever logged • At end of the session, all commands entered are added to the file ~/.bash_history. exec /usr/bin/pine # when pine exits, the session is over If this is put in a user’s ~/.profile, that user will automatically run pine when logging. contents of ~/.profile can include a exec command to replace the shell Ex:
  • 19. GNU and Unix Commands Recursive commands 19 Recursion in terms of Linux commands refers to applying a command to a all the files in a directory, and all the files in all the subdirectories (and subdirectories of subdirectories). $ find /etc -type f -exec cat {} ; # find with find, then cat each one Ex: Some commands (ls, chown, chmod, cp, rm, grep) support switches – R or – r . commands without recursive mode, combine the cmd with find to achieve your results. find ... Exec can execute a specific command each time a file is found: $ cat `find -type f /etc` # cat whatever find says $ find /etc -type f | xargs cat # run cat with parameters from find The output of find can list file names on the command line: Using parameter -type f to find ensures that we only consider regular files. find can use other criteria to identify files - name, permissions, modification, date, etc.
  • 20. GNU and Unix Commands man pages 20 The primary (and traditional) source of documentation is the manual pages, which can be accessed using command: man command or man section command Manual pages are usually installed when you install a package, so if you do not have a package installed, you probably won't have a manual page for it. Manual pages have: •A heading with the name of the command followed by its section number in parentheses •The name of the command and any related commands that are described on the same man page •A synopsis of the options and parameters applicable to the command •A short description of the command •Detailed information on each of the options There might be other sections on usage, how to report bugs, author information, and a list of related commands. For example, the man page for man tells us that related commands (and their manual sections) are: apropos(1), whatis(1), less(1), groff(1), and man.conf(5).
  • 21. GNU and Unix Commands man pages 21 There are 8 common manual page sections: 1. User commands (env, ls, echo, mkdir, tty) 2. System calls or kernel functions (link, sethostname, mkdir) 3. Library routines (acosh, asctime, btree, locale, XML::Parser) 4. Device related information (isdn_audio, mouse, tty, zero) 5. File format descriptions (keymaps, motd, wvdial.conf) 6. Games (note that many games are now graphical and have graphical help outside the man page system) 7. Miscellaneous (arp, boot, regex, unix utf8) 8. System administration (debugfs, fdisk, fsck, mount, renice, rpm) Other sections could include: 9.for Linux kernel documentation, n. new documentation, o. old documentation, l. local documentation. 2 important commands related to man are whatis and apropos. whatis - searches man pages for the name given and displays name info from appropriate manual pages. apropos - does a keyword search of manual pages and lists ones containing the keyword.
  • 22. commands . The current directory bash What you bash your commands into echo echo env Show environment variables exec Run and don’t return export Add a variable to the export list man Manual pages pwd Print working directory set Show environment settings unset Clear an environment variable ~/.bash_history The last n commands you typed ~/.profile What runs when you login interactively Test commands for exam 22 GNU and Unix Commands