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

Linux Commands From Syllabus

Uploaded by

woyevi6712
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)
37 views

Linux Commands From Syllabus

Uploaded by

woyevi6712
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/ 41

Introduction to Linux

Linux Directory structure


• Common Directories
– / (directory separator)
– / “Root”, top of the file system hierarchy
– /bin Binaries and other executable programs or files
– /etc System configuration files
– /home User home directories
– /opt Optional or third party software
– /tmp Temporary space(typically cleared on reboot)
– /usr User related programs
• /usr/local/
– /var Variable data (most notably log files)
Some other directories
• /boot Files needed to boot the operating system
• /cdrom Mount point for CD-ROMs
• /cgroup Control group hierarchy
• /dev Device files (typically controlled by OS and sys admins)
• /export Shared file systems
• /lib System libraries
• /lib64 System libraries (64bit)
• /lost+found Used by system to store recovered files after file systems check has
been performed
• /media Used to mount removable media like CD-ROMs
• /mnt Used to mount external file systems
• /proc Provides info about running processes
Linux Shell
• Default interface to Linux
– If connecting to Linux machine over the network (S_ _?)
– Text-based login prompt

• The GUI is also referred to as a graphical shell.

• An application that accepts user commands and executes


them.

• Also known as a Command Line Interpreter


Types of Linux/ Unix Shells
• bash+ (Bourne Again Shell)

• ksh+ (Korn Shell)

• tcsh (derived from csh, Berkely Unix C shell)

• zsh

• fish (Friendly Interactive Shell)


Shell Prompt

• Once a shell is started


– Initialization
– Waiting for command
• Prompt gives useful information

Logged in mach Logged mach System


System
User ine in User ine connected to a
connected to a
regular user super user
* This root is different from the file system root
Superuser, root
• Root is all powerful* ( do not leave this account open)
– Similar to administrator account on Windows

• Normal user accounts can only do a subset of the functions


root can do.

• Root access may be required to


– Install programs
– Start/ stop an application
– Change/ access configuration files
Different ways the prompt can presented

user@mece_svr $ ~user -----> /home/user

[user@mece_svr ~user2 ----->


/tmp]$ /home/user2

mece_svr: ~root -----> /root


/home/user>
~ftp -----> /srv/ftp
user@mece_svr:~> (services)
How to customize the shell will be covered in latter sections
Linux commands
• Commands are case sensitive
Ls ≠ ls ≠ LS
• ls – list directory contents
• cd – change the current directory
• pwd – display the present working directory
• cat – concatenates and display files
• echo – Display arguments to the screen.
• man – Display the online manual
• exit – Exits the shell or your current session
• clear – Clears the screen
**Most commands have additional arguments(options) you can add**
Linux commands- navigating the man pages
• Enter – Moves down one line

• Space – Move down one page

• g – Move to the top of the page

• G – Move to the bottom of the page

• q – Quit

man [command]
Linux commands
• [command]--help or [command]-h,
gives more info on particular command
– Sometimes doesn’t work (use man instead then)

• man –k [SEARCH_TERM], for when you


are not sure of the command to use)
printf command in Linux with Examples

“printf” command in Linux is used to display the


given string, number or any other format
specifier on the terminal window. It works the
same way as “printf” works in programming
languages like C. Syntax:$printf [-v var] format
[arguments]

Note: printf can have format specifiers, escape


sequences or ordinary characters.
Format Specifiers: The most commonly used
printf specifiers are %s, %b, %d, and %f.
• %s specifier: It is basically a string specifier for
string output.
• $printf "%s\n" "Hello, World!"
• Output:
%b specifier:
• It is same as string specifier but it allows us to interpret
escape sequences with an argument.
• Input: printf "%s\n" "Hello, World! \n" "From Geeks For
Geeks\n"
• Output: Hello, World! \n
From Geeks For Geeks\n

Note: The escape sequence “\n” in the above lines has no


special meaning when used with “%s” specifier and is
treated just like other characters.
• If we replace “%s” with “%b“, Then it will be
interpreted as a newline character.
• Input : printf "%b\n" "Hello, World! \n" "From
Geeks For Geeks\n"
• Output: Hello, World!
From Geeks For Geeks
%d specifier:
• It is an integer specifier for showing the
integral values.
• $printf "%d\n" "213" "109"
• Output:
213
109
%f specifier:
• It is used for output of floating point values.
• $printf "%f\n" "1.32" "3.14“
• Output :
1.320000
3.140000
• What is the Purpose of the uname Command
in Linux?
• The uname command in Linux is used to
retrieve essential information about the
system. It provides details such as the kernel
name, version, machine hardware name,
operating system, and more. It is a versatile
tool commonly used for system identification
and scripting purposes.
• Syntax of uname Command in Linux
• The basic syntax of uname command is as
follows:
uname [OPTIONs]
• -a or --all : Displays all available information.
• -s or --kernel-name :Shows the kernel name.
• -n or --nodename :Displays the network (domain)
name of the machine.
• -r or --kernel-release : Shows the kernel release.
• -v or --kernel-version : Displays the kernel version.
• -m or --machine : Shows the machine hardware name.
• -p or --processor : Displays the processor type or
“unknown.”
• -i or --hardware-platform : Shows the hardware
platform or “unknown.”
• -o or --operating-system :Displays the operating
system.
1. -a option in uname Command in Linux
• It prints all the system information in the
following order: Kernel name, network node
hostname, kernel release date, kernel version,
machine hardware name, hardware platform,
operating system.
• Syntax:
uname -a
2. -s option in uname Command in Linux
• It prints the kernel name.
• Syntax:
uname -s
3. -n option in uname Command in Linux
• It prints the hostname of the network
node(current computer).
• Syntax:
uname -n
4. -r option in uname Command in Linux
• It prints the kernel release date.
• Syntax:
uname -r
5. -v option in uname Command in Linux
• It prints the version of the current kernel.
• Syntax:
uname -v
• 6. -m option in uname Command in Linux
• It prints the machine hardware name.
• Syntax:
uname -m
• 7. -p option in uname Command in Linux
• It prints the type of the processor.
• Syntax:
uname -p
8. -i option in uname Command in Linux
• It prints the platform of the hardware.
• Syntax:
uname -i
9. -o option in uname Command in Linux
• It prints the name of the operating system.
• Syntax :
• uname -o
WHO
• The who command displays information about
all users currently on the local system.
• The following information is displayed:
login name, tty (There is a command called tty which displays
information related to the terminal), date and time of login.
Date
Stty

You might also like