CompTIA Linux+ Powered by LPI certifies foundational skills and knowledge of Linux. With Linux being the central operating system for much of the world’s IT infrastructure, Linux+ is an essential credential for individuals working in IT, especially those on the path of a Web and software development career. With CompTIA’s Linux+ Powered by LPI certification, you’ll acquire the fundamental skills and knowledge you need to successfully configure, manage and troubleshoot Linux systems. Recommended experience for this certification includes CompTIA A+, CompTIA Network+ and 12 months of Linux admin experience. No prerequisites required.
2. Linux directories
• What are Commands
A command is an instruction given to our computer by us to do
whatever we want. In Mac OS, and Linux it is called terminal,
whereas, in windows it is called command prompt. Commands are
always case sensitive.
• Commands are executed by typing in at the command line followed
by pressing enter key.
• This command further passes to the shell which reads the command
and execute it. Shell is a method for the user to interact with the
system. Default shell in Linux is called bash (Bourne-Again Shell).
3. Linux directories
• The Root Directory
All the directories in the Linux system comes under the root directory
which is represented by a forward slash (/). Everything in your system can
be found under this root directory even if they are stored in different
virtual or physical devices.
4. Linux directories
• 1. / – Root
Every single file and directory starts from the root directory.
Only root user has write privilege under this directory.
Please note that /root is root user’s home directory, which is not
same as /.
• 2. /bin – User Binaries
Contains binary executables.
Common linux commands you need to use in single-user modes are
located under this directory.
Commands used by all the users of the system are located here.
For example: ps, ls, ping, grep, cp.
5. Linux directories
• 3. /sbin – System Binaries
Just like /bin, /sbin also contains binary executables.
But, the linux commands located under this directory are used
typically by system aministrator, for system maintenance purpose.
For example: iptables, reboot, fdisk, ifconfig, swapon
• 4. /etc – Configuration Files
Contains configuration files required by all programs.
This also contains startup and shutdown shell scripts used to
start/stop individual programs.
For example: /etc/resolv.conf, /etc/logrotate.conf
6. Linux directories
• 5. /dev – Device Files
Contains device files.
These include terminal devices, usb, or any device attached to the
system.
For example: /dev/tty1, /dev/usbmon0
• 6. /proc – Process Information
Contains information about system process.
This is a pseudo filesystem contains information about running process.
For example: /proc/{pid} directory contains information about the
process with that particular pid.
This is a virtual filesystem with text information about system
resources. For example: /proc/uptime
7. Linux directories
• 7. /var – Variable Files
var stands for variable files.
Content of the files that are expected to grow can be found under
this directory.
This includes — system log files (/var/log); packages and database
files (/var/lib); emails (/var/mail); print queues (/var/spool); lock
files (/var/lock); temp files needed across reboots (/var/tmp);
• 8. /tmp – Temporary Files
Directory that contains temporary files created by system and users.
Files under this directory are deleted when system is rebooted.
8. Linux directories
• 9. /usr – User Programs
Contains binaries, libraries, documentation, and source-code for second level
programs.
/usr/bin contains binary files for user programs. If you can’t find a user binary
under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
/usr/sbin contains binary files for system administrators. If you can’t find a system
binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd,
userdel
/usr/lib contains libraries for /usr/bin and /usr/sbin
/usr/local contains users programs that you install from source. For example,
when you install apache from source, it goes under /usr/local/apache2
10. /home – Home Directories
Home directories for all users to store their personal files.
For example: /home/john, /home/nikita
9. Linux directories
• 11. /boot – Boot Loader Files
Contains boot loader related files.
Kernel initrd, vmlinux, grub files are located under /boot
For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-
24-generic
12. /lib – System Libraries
Contains library files that supports the binaries located under
/bin and /sbin
Library filenames are either ld* or lib*.so.*
For example: ld-2.11.1.so, libncurses.so.5.7
10. Linux directories
• 13. /opt – Optional add-on Applications
opt stands for optional.
Contains add-on applications from individual vendors.
add-on applications should be installed under either /opt/ or
/opt/ sub-directory.
14. /mnt – Mount Directory
Temporary mount directory where sysadmins can mount
filesystems.
11. Linux directories
• 15. /media – Removable Media Devices
Temporary mount directory for removable devices.
For examples, /media/cdrom for CD-ROM;
/media/floppy for floppy drives; /media/cdrecorder for
CD writer
16. /srv – Service Data
srv stands for service.
Contains server specific services related data.
For example, /srv/cvs contains CVS related data.
12. Linux Commands
• whoami
Use whoami to find out who you are logged in as or who is
logged into an unmanned Linux terminal
• pwd
Nice and simple, the pwd command prints the working
directory (the current directory) from the root / directory
• man
The man command displays the “man pages” for a command
in less . The man pages are the user manual for that
command. Because man uses less to display the man pages,
you can use the search capabilities of less
13. Linux Commands
• ls
This might be the first command the majority of Linux users meet. It
lists the files and folders in the directory you specify. By default, ls
looks in the current directory. There are a great many options you
can use with ls , and we strongly advise reviewing its the man page.
Some common examples are presented here
• mkdir
The mkdir command allows you to create new directories in the
filesystem. You must provide the name of the new directory to
mkdir. If the new directory is not going to be within the current
directory, you must provide the path to the new directory.
To create two new directories in the current directory called
“invoices” and “quotes,” use these two commands
14. Linux Commands
• mv
The mv command allows you to move files and directories
from directory to directory. It also allows you to rename files.
To move a file you must tell mv where the file is and where
you want it to be moved to. In this example, we’re moving a
file called apache.pdf from the “~/Document/Ukulele”
directory and placing it in the current directory, represented
by the single . character
• w
The w command lists the currently logged in users.
15. Linux Commands
• uname
You can obtain some system information regarding the Linux computer
you’re working on with the uname command.
Use the -a (all) option to see everything.
Use the -s (kernel name) option to see the type of kernel.
Use the -r (kernel release) option to see the kernel release.
Use the -v (kernel version) option to see the kernel version.
• less
The less command allows you to view files without opening an editor. It’s
faster to use, and there’s no chance of you inadvertently modifying the
file. With less you can scroll forward and backward through the file using
the Up and Down Arrow keys, the PgUp and PgDn keys and the Home and
End keys. Press the Q key to quit from less
16. Linux Commands
• tail
The tail command gives you a listing of the last 10 lines of a file. If you want to
see fewer or more lines, use the -n (number) option. In this example, we use
tail with its default of 10 lines. We then repeat the command asking for only
five lines.
• head
The head command gives you a listing of the first 10 lines of a file. If you want
to see fewer or more lines, use the -n (number) option. In this example, we
use head with its default of 10 lines. We then repeat the command asking for
only five lines
• sudo
The sudo command is required when performing actions that require root or
superuser permissions, such as changing the password for another user.
17. Linux Commands
• history
The history command lists the commands you have previously issued on
the command line. You can repeat any of the commands from your history
by typing an exclamation point ! and the number of the command from
the history list
• SSH
Use the ssh command to make a connection to a remote Linux computer
and log into your account. To make a connection, you must provide your
user name and the IP address or domain name of the remote computer
• shutdown
The shutdown command lets you shut down or reboot your Linux system.
Using shutdown with no parameters will shut down your computer in one
minute
18. Linux Commands
• grep
The grep utility searches for lines which contain a search pattern.
When we looked at the alias command, we used grep to search
through the output of another program, ps . The grep command can
also search the contents of files. Here we’re searching for the word
“train” in all text files in the current directory
The ps command lists running processes. Using ps without any
options causes it to list the processes running in the current shell
ping
The ping command lets you verify that you have network
connectivity with another network device. It is commonly used to
help troubleshoot networking issues. To use ping, provide the IP
address or machine name of the other device
19. Linux Commands
• passwd
The passwd command lets you change the password for a
user. Just type passwd to change your own password.
You can also change the password of another user account,
but you must use sudo. You will be asked to enter the new
password twice
kill
The kill command allows you to terminate a process from the
command line. You do this by providing the process ID (PID)
of the process to kill. Don’t kill processes willy-nilly. You need
to have a good reason to do so. In this example, we’ll
pretend the shutter program has locked up
20. Linux Commands
• groups
The groups command tells you which groups a user is a member of
• The gzip command compresses files. By default, it removes the original
file and leaves you with the compressed version. To retain both the
original and the compressed version, use the -k (keep) option
• free
The free command gives you a summary of the memory usage with your
computer. It does this for both the main Random Access Memory (RAM)
and swap memory. The -h (human) option is used to provide human-
friendly numbers and units. Without this option, the figures are presented
in bytes
21. Linux Commands
• finger
The finger command gives you a short dump of information about a
user, including the time of the user’s last login, the user’s home
directory, and the user account’s full name
find
Use the find command to track down files that you know exist if you
can’t remember where you put them. You must tell find where to
start searching from and what it is looking for
exit
The exit command will close a terminal window, end the execution
of a shell script, or log you out of an SSH remote access session
22. Linux Commands
• echo
The echo command prints (echoes) a string of text to the
terminal window
• diff
The diff command compares two text files and shows the
differences between them. There are many options to tailor
the display to your requirements
• df
The df command shows the size, used space, and available
space on the mounted filesystems of your computer.
23. Linux Commands
• Two of the most useful options are the -h
(human readable) and -x (exclude) options.
The human-readable option displays the sizes
in Mb or Gb instead of in bytes. The exclude
option allows you to tell df to discount
filesystems you are not interested in
24. Linux Commands
• curl
The curl command is a tool to retrieve information and
files from Uniform Resource Locators (URLs) or internet
addresses.
The curl command may not be provided as a standard
part of your Linux distribution. Use apt-get to install
this package onto your system if you’re using Ubuntu
or another Debian-based distribution. On other Linux
distributions, use your Linux distribution’s package
management tool instead
25. Linux Commands
• chown
The chown command allows you to change the owner
and group owner of a file. Listing our example.txt file
with ls -l we can see dave dave in the file description.
The first of these indicates the name of the file owner,
which in this case is the user dave. The second entry
shows that the name of the group owner is also
dave. Each user has a default group created when the
user is created. That user is the only member of that
group. This shows that the file is not shared with any
other groups of users
26. Linux Commands
• chmod
The chmod command sets the file permissions flags on a file
or folder. The flags define who can read, write to or execute
the file. When you list files with the -l (long format) option
you’ll see a string of characters that look like
cd
The cd command changes your current directory. In other
words, it moves you to a new place in the filesystem.
If you are changing to a directory that is within your current
directory, you can simply type cd and the name of the other
directory
27. Linux Commands
• cat
The cat command (short for “concatenate”) lists the contents of files
to the terminal window. This is faster than opening the file in an
editor, and there’s no chance you can accidentally alter the file. To
read the contents of your .bash_log_out file, type the following
command while the home directory is your current working
directory, as it is by default
alias
The alias command lets you give your own name to a command or
sequence of commands. You can then type your short name, and
the shell will execute the command or sequence of commands for
you