0% found this document useful (0 votes)
52 views38 pages

Linux Hand On

The document provides a comprehensive guide to the Linux root directory and its structure, detailing essential directories and their purposes, such as /bin for binaries, /etc for configuration files, and /home for user files. It explains how to navigate the file system using commands like 'cd', 'ls', and 'pwd', as well as the importance of man pages for command documentation. Additionally, it covers file and directory commands, including creating, moving, and deleting directories and files, while distinguishing between absolute and relative paths.

Uploaded by

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

Linux Hand On

The document provides a comprehensive guide to the Linux root directory and its structure, detailing essential directories and their purposes, such as /bin for binaries, /etc for configuration files, and /home for user files. It explains how to navigate the file system using commands like 'cd', 'ls', and 'pwd', as well as the importance of man pages for command documentation. Additionally, it covers file and directory commands, including creating, moving, and deleting directories and files, while distinguishing between absolute and relative paths.

Uploaded by

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

Hands-On Linux: A Practical Guide to Directories,

Commands, Users, File Systems, Permissions, and


Package Management

By Temitope Adeniyi G

Linux Root Directory and Its


Structure
What is the Root Directory (/)?

The root directory (/) is the starting point of the Linux file system. It’s the parent of all files
and directories in the system.
It’s essential for the system to boot and operate because critical files and directories are
organized under it.
The root directory provides the framework to ensure that everything in Linux , whether it’s
user files, applications, or system logs , is stored in the right place.
The root directory is like a tree with branches. Every branch (file or directory) branches out
from the root.
Now lets navigate to the root directory, to do this, use ‘cd’ command which means change
directory, and (/ ) the sign for the root directory is (/)

Pwd is the command to check your present working directory, as you can see the output (/)
meaning I am in the root directory, don’t worry if this gets confusing at first, just hang on, you
will get it.

Contents of the Root Directory

Now let’s check the directories under the root directory, remember, these directories are there
because they are essential for the system to boot and operate. To list this directory, we would
use the command (ls)
I want these files to be listed vertically rather than horizontally as seen above, I will use the
command (ls) with an option (-l) to give me (ls -l)

Directories Under the root directory and Their Purpose

1. bin (symbolic link to usr/bin) : This directory contains essential binaries (commands)
needed for the system to function. These include basic commands like ls, cp, and cat. In
your system, it is linked to usr/bin for consistency. Think of it as a toolbox that holds
essential tools for both you and the system. No matter what happens, the system always
knows where to find these critical tools.
2. boot : This contains the files required to boot (start) the system, such as the Linux kernel
(vmlinuz) and bootloader configuration files (like GRUB). This is like the engine of a car.
Without it, the system cannot start.
3. dev : This directory contains device files that represent hardware like disks, USB drives, and
printers.
4. etc: The configuration files for the system and software are stored here like an
administrative office of the system, where all the rulebooks and policies (configs) are kept.
5. home: This is where personal files for each user are stored.
6. lib (symbolic link to usr/lib) : This contains shared libraries (like .so files) used by programs
in /bin and /sbin. Think of libraries in /lib as books that programs borrow to understand how
to work.
7. lost+found: This is a special directory created by the file system to store corrupted or
recovered files during system repairs. Like a lost-and-found box where recovered items are
stored until claimed.
8. media: This is where removable media like USB drives and CDs are mounted when
connected. This is like the parking lot for removable devices.
9. mnt: This is a temporary mount point for manually mounting file systems.
10. opt: This is used for installing optional or third-party software.
11. proc: This is a virtual directory that provides information about running processes and
system resources. For example, /proc/cpuinfo shows details about the CPU. This is the
control room where you can monitor the system’s internal workings.
12. root: This is the home directory for the root user (superuser), separate from regular users’
/homedirectories.
13. run: This directory contains runtime data for system processes, and temporary sockets.
This is like a real-time message board where processes leave notes for the system.
14. sbin (symbolic link to usr/sbin): This contains essential system binaries for
15. snap: This is specific to systems using Snap packages, a modern way of distributing
applications. It contains application files installed via Snap. Like an app store directory for
Snap-installed software.
16. srv: This directory is meant for data served by the system, such as web files for a web
server. Think of this as the public library where shared resources are made available.
17. sys: This is another virtual directory like /proc, but it focuses on exposing information about
hardware devices.
18. tmp: This directory is used for storing temporary files that applications create. It is usually
cleared upon reboot.
19. usr: This directory contains user-installed applications and libraries. Subdirectories like
/usr/bin and /usr/sbin house programs and system administration tools.
20. var: This directory contains files that are expected to grow, such as logs (/var/log), caches,
and spool files.

Now lets look at the content of the /etc directory for example, which is the directory that
contains the configuration files, remember the command to change directory is (cd) and the
command to list the directory is (ls) while (pwd) is the command to check the current directory
you are in.
Output: these are configuration files

As you can see, when we wanted to change the directory to /etc, we had to start with /, which is
the root directory — the starting point of the Linux file system. It’s like the trunk of a tree, and all
other directories branch out from it. On your own, you can explore the other directories under /
and read more about their purposes.

For now, I want to navigate to the home directory of the current user (ubuntu), which is like my
personal house where I can store anything and create my own files or directories. To do that, I
will run the command:

This navigates to my own home directory, no matter where it is located. The ~ symbol (tilde) is
shorthand for the current user’s home directory.

This is different from the /home directory under the root directory. For example, if I type:
It will take me to the /home directory, which is the parent directory for all users' home
directories on the system. Each user’s home directory is stored as a subdirectory under /home.
its showing ubuntu because it is the only user we have yet. Let’s go on with user ubuntu(default
user) later we will learn how to create more users.

Now I am in the home directory of ubuntu, this is where I will run all my commands and create
my files and folders.

Man Pages (Manual Pages)


What Are Man Pages?
Man pages, short for manual pages, are the built-in documentation for Linux commands,
programs, and system files. Each man page provides detailed information about a specific
command, including:

What the command does.


Its syntax (how to use it).
Options (additional features or settings).
Examples of usage.

Man pages are like instruction manuals or user guides for tools in a toolbox. Whenever you’re
unsure how a tool works, you can consult the manual for help.

Why Are Man Pages Important?


They serve as the go-to reference for understanding commands without needing internet
access. They’re organized into sections based on the type of content (e.g., user commands,
system calls, configuration files).

How to Use Man Pages


You type, man (command), for example so far we have used (ls and pwd) commands, now let’s
check their man pages.

man command
This displays the manual for the ls command, explaining what it does and its options.

To quit this man page, press q on your keyboard

Let check for (pwd)

This displays the manual for the pwd command, explaining what it does and its options.
Options and Arguments
Options are used to modify the behavior of a command. They typically start with a dash (-) and
are followed by a letter or word.

For example:

ls: Basic command.


ls -l: Adds the long listing format option, providing more details. Let’s say you are
ordering coffee. By default, the coffee shop gives you a plain black coffee (ls). But if you
want something extra, like milk or sugar, you add "options" to your order (ls -l).

You can combine more than 2 options for example,

The ls command lists the contents of a directory.


The -la combination consists of two options:

1. -l (long format): Displays detailed information about files and directories, such
as permissions, ownership, size, and modification date.
2. -a (all): Includes hidden files (files that start with a dot .) in the listing. Hidden
files are usually system files or configurations.

The ls -la command is like saying: "Show me everything in the room, including
what’s hidden, and give me detailed information about each item."

Arguments

Arguments specify the target on which the command should operate.

ls: Operates on the current directory by default.


ls Temitope: The ‘Temitope’ directory is the argument, telling ls to list files there.

Continuing with the coffee analogy, the argument is like specifying which coffee shop you want
your order from. for example: "Order coffee from Shop A (ls Temitope)." meaning list the
contents in the ‘Temitope’ directory

Ps: I created directory (Temitope), and then another directory (Gbadamosi) inside it for
context. Do not worry, you will learn how to create directories too, soon.

You can explore more commands with options and arguments using the man pages. I hope you
now understand the concepts of options and arguments. Hang on, You’ve got this!

Commands for Working with


Directories
What is a directory
A directory is a folder that is used to organize and group files (or other directories) together in a
structured way. Think of a directory as a folder on your laptop, where you can store multiple
documents or even other folders (subdirectories).

What Are Directory Commands?


In Linux, directories are used to organize files into a structured hierarchy.

Directory commands help you create, navigate, remove, and manipulate these directories oe
what you may understand as folders.

Command 1: pwd (Print Working Directory)

Displays the current directory you are in. It’s like asking, "Where am I right now?"

Command 2: ls (List Directory Contents)

Lists files and subdirectories in the current directory.

Basic listing

Detailed listing with permissions, sizes, etc.

Command 3: cd (Change Directory)

Used to navigate between directories. It’s like moving from one room to another in a house.

To go to the /home directory:


To go back to my home directory:

Command 4: mkdir (Make Directory)

Creates a new directory. It’s like building a new room in a house.

mkdir foldername

To create multiple directories at once

mkdir foldernames spaced

To create nested directories, that is one directory inside another directory

mkdir -p Tope/loves/food

What It Does:

mkdir: This command creates directories.


-p (Parent): Ensures that if any parent directories in the path don’t exist, they will be created
automatically.
Tope/loves/food: This specifies the full directory structure:
Tope is the main (parent) directory.
Inside Tope, the loves directory is created.
Inside loves, the food directory is created.

cd ..

What It Does:

cd .. moves you up one level in the directory structure:


If you’re in ~/Tope/loves, cd .. takes you back to ~/Tope.
Running cd .. again takes you back to your home directory (~) as seen above

Command 5: rmdir (Remove Directory: Removes an empty directory.

rmdir foldername

As you can see when i tried to remove Temitope’s directory, I got a message telling me the
directory is not empty, because you can only rmdir for an empty directory. Fred was empty, so
the rmdir worked and when I typed ls to list the content of the directory, Fred has been deleted.

Command 6: rm -r (Remove Directory and Its Contents)

rm -r foldername

Deletes a directory and all its contents (files and subdirectories). Now this will work for
Temitope’s folder that had contents in it.

To remove multiple directories use rm -r and list all the directories one after the other.

NOTE: Linux is case sensitive, Tope with capital letter T is different from tope with small letter t.
just thought to chip that in

Now, those directories have been deleted.


Command 7: mv (Move or Rename a Directory)

Moves or renames a directory. It’s like moving a room to a different part of the house or
renaming it.

mv foldername1 foldername2

Command 8: cp -r (Copy Directory)

cp -r foldername1 foldername2

Copies a directory and its contents. It’s like making a duplicate of a room with all its items.

ls: Lists the contents of the current directory, showing directories enemy, folder1, and no files.

cp -r enemy friend: Copies the enemy directory (and its contents) into a new directory called
friend. -r option enables recursive copying, allowing you to copy directories and their contents.

ls (after copying): Confirms the creation of friend as a copy of enemy.

cd enemy: Moves into the enemy directory.

ls (inside enemy): Shows cynthia as a file or directory inside enemy.

cd ..: Moves back to the parent directory.

cd friend: Moves into the friend directory (a copy of enemy).

ls (inside friend): Shows cynthia as it was copied from enemy.

Absolute and Relative Paths


What Are Paths in Linux?

A path is the location of a file or directory in the Linux file system.


Paths tell Linux where to find a file or directory, similar to an address in a city.

Absolute Paths

An absolute path specifies the location of a file or directory starting from the root directory
(/).
It always begins with /. That is an absolute path starts from the root directory (/), so it gives
the complete location of a file or folder.

If the folder enemy is inside /home/ubuntu, the absolute path is /home/ubuntu/enemy

It’s like giving someone the full address to a house, starting from the main city:
Example: "City → Neighborhood → House."

Relative paths
specifies the location of a file or directory relative to your current directory.

It does not start with /. A relative path starts from your current location. It’s like giving
directions based on where you currently are: Example: “when you get to enemy, turn left, then
walk two houses down, you will topsy ." notice it is relative to home/ubuntu my current directory

I cd to enemy (I apologize, I could have used a better word)

I created a directory (topsy) Inside enemy

then ran
Command: cd enemy/topsy

What I Did:
Navigated into the topsy directory inside enemy.
Why:
enemy/topsy is a relative path from /home/ubuntu, allowing me to specify a location
without using an absolute path.

Command: pwd

What I Did:
Checked your current directory, which displayed /home/ubuntu/enemy/topsy.
Why:
To confirm that you successfully navigated to the topsy directory.

Key Differences

Feature Absolute path Relative path

Starts From Root directory (/) Current working directory

Works From Anywhere? Yes Only if you're in the correct


location

Syntax Always starts with / Does not start with /

One important thing to note about absolute paths is that you can run them from anywhere in
the file system, regardless of your current directory. As long as you know the full path, it will take
you directly to the desired location.

For relative paths, you must be in the correct starting directory for the path to work. Relative
paths depend on your current location in the file system.

Commands for Working with Files


in Linux
What is A File
A file is a container for storing data. It can contain text, code, images, videos, or any type of
information. Think of a file as a document in your computer, it could be a Word document, a PDF,
or an image.

What Are File Commands?

File commands in Linux are used to create, view, edit, move, copy, delete, and manipulate
files.

Command 1: touch (Create an Empty File)

touch filename

Creates an empty file or updates the timestamp of an existing file.

Command 2: vi (Edit a File)

vi filename

Opens the file in a text editor to make changes.

The text editor opens


You can write in it by pressing letter i (which means insert)
what it looks like after pressing ( i ) for insert on my keyboard
After you write in it, to exit the editor and save your input press esc (escape) on your keyboard
and then :wq! (save and quit) and press enter. To exit without saving your new changes, press
esc and then :q! (quit) and press enter

Command 3: cat (Concatenate and Display)

Displays the entire content of a file.

Cat filename

As you can see from the above, the cat command displayed the content of that file i just wrote in

Command 4: wc (Word Count)

wc filename

Displays the number of lines, words, and characters in a file.


1- line showing 1 line

7- showing 7 words

44- showing that it contains 44 characters

Command 5: grep (Search for Patterns)

Purpose: Searches for a specific word or phrase in a file and displays matching lines.

Remember linux is case sensitive when i did grep “devops” file1.txt, i didn’t get any output
because it didn’t find that pattern, but when i did a case-Insensitive search using the option (-i),
it gave me the result regardless of whether it is a small or capital letter.

Command 6: cp (Copy a File)

cp filename

Creates a duplicate of a file.

See that myfile is now a duplicate of file1.txt

Command 7: mv (Move or Rename a File)

Moves a file to another location or renames it.


Redirection Commands in Linux
What Is Redirection?

Redirection allows you to control where the output of a command goes (e.g., to a file instead
of the screen) or where the input of a command comes from (e.g., from a file instead of
typing).

‘Echo’ command
What Is the echo Command?

The echo command is used to display a string or text on the terminal.


It is commonly used in scripts to output messages or print variable values.
Think of echo as a loudspeaker: You give it a message, and it repeats it back on the screen.

1. Output Redirection
Command 1: > greater than sign (Redirect Output to a File)

Let’s use this with the echo command

Redirects the output of a command to a file, overwriting the file if it exists.

The command echo “Temitope is a pharmacist turned devops and devsecops enginneer”
redirected the output of the echo command which should normally display the screen into
file1.txt and overwrote existing content. “Temitope is a Devops and Devsecops enginneer”

Command 2: >> (Append Output to a File)

Redirects the output of a command to a file, appending (adding ) to the file if it exists. it
does not overwrite the existing content unlike command (>)
2. Input Redirection
Command 1: < (Redirect Input from a File

Redirects input for a command from a file instead of typing it manually.

Reads the content of file.txt and displays it on the screen.

3. Combining Input and Output Redirection


Command: command <filename > filename

Redirects input from one file and sends the output to another.

The command above redirected the output of cat < file1.txt which is to read and display the
content of file1.txt, into another file file2.txt

4. Error Redirection
Command: 2> (Redirect Error Output to a File)

Redirects error messages (stderr) to a file. Standard error (stderr) is the output you get
when the shell encounters an error, and it's usually displayed on the screen. For example, if
I ask the shell to list the contents of a non-existent file, I will get an error message - No such
file or directory

I am asking it to list the nofile with the command (ls nofile), which does not exist. Instead of
having the output display on my screen, I can redirect it into another file for analysis or audit
later.

ls nofile 2> errorlogs.txt

Saves the error message to error.log and also creates error.log file is it’s not existing.

5. Pipes (|)
Command: | (Pipe Output to Another Command)

Sends the output of one command as input to another command.

ls | grep file

ls: Lists all files and directories in the current directory.


|: Sends the output of ls as input to grep.
grep file: Filters the list and displays only the lines that contain the word "file."

for context, this is the output of running ls -l,

ls -l | grep file basically ls pipe grep file, the pipe send the ouput as input to the
grep command, grep filters only for files containing the word ‘file’

How to Differentiate Between a File and a Directory


Look at the first character in the output:
- → Indicates a file.
d → Indicates a directory.
Sometimes directories are colored, files have no color

Linux Link Commands


What Are Links in Linux?

Links in Linux are pointers or shortcuts to files and directories. They allow you to reference a
file or directory without duplicating its contents. Think of a link as a shortcut icon on your
desktop that points to an actual file or folder somewhere else. Clicking the shortcut takes
you to the original file.

Types of Links

1. Hard Link
a. A hard link is a direct reference to the physical data of a file on disk.
b. Even if the original file is deleted, the hard link still holds the data.
2. Soft Link (Symbolic Link)
A soft link is a shortcut to the original file or directory.
If the original file is deleted, the soft link becomes broken.

Commands:

ln (Create a Hard Link)


Lets practice

1 Create a file:

2 Create a hard link:


3 Verify the link:

Notice the same file size and link count for original.txt and hardlink.txt.

4 Delete the original file:

5 Check that the hard link still works:

ln -s (creates a Soft Link)


1 Create a file:

2 Create a soft link:

3 Verify the soft link

4 Delete the original file:


5 Try accessing the soft link:

The link is broken since the target no longer exists.

Permissions in Linux
What Are Permissions in Linux?

Linux permissions determine who can access a file or directory and what actions they can
perform.
For every file and directory, permissions are defined for three types of users:
1. Owner: The user who created the file or directory.
2. Group: A collection of users who share access.
3. Others: Everyone else on the system.
Think of permissions like keys to a house:
The owner has the master key.
The group has limited access to shared areas.
Others may only see the house from outside but can’t enter.

Linux permissions can be expressed in two ways:


1. Letter Type: Uses symbolic characters (r, w, x) to represent permissions.
2. Number Type: Uses octal numbers (4, 2, 1) to represent permissions.

Understanding Permission Representation


1. Symbolic Representation

Permissions are displayed in 10 characters when you use ls -l:


First Character:

Indicates the file type:


- → Regular file.
d → Directory.
l → Symbolic link.

Next 9 Characters: Represent permissions in three groups of three:

let’s take errorlogs.txt (no 2 on the list ) file for example, the permissions are

r - read

w- write

x- execute

rw- (Owner): Read (r), write (w), no execute (-).


rw- (Group): Read (r), write (w), no execute (-).
r-- (Others): Read-only.

Numeric Representation (Octal Mode)


Each permission is represented by a number:
4 → Read (r).
2 → Write (w).
1 → Execute (x).
0 → No permission.
Combine numbers for permissions:
Example: rw- = 4 (read) + 2 (write) = 6.
Common numeric permissions:
777 → Full access for everyone (owner, group, others).
644 → Read and write for owner, read-only for group and others.

Practical Tasks

Task 1
Create a file

list it to via permissions

The default permission on this newly created file is rw (read and write) for owner, rw (read and
write) for group and R(execute for others)

in numerical value, this permission will be 664 that is (r-4 + w-2 = 6) for owner, (r-4 + w+2 = 6) for
owner, and (R-4) for others, that gives us 664 permission.

Now to modify this permission using letters, we will use chmod command

This command modifies the permissions of the file linuxclass.txt for the owner, group, and
others. Each part of the command specifies different permissions for these categories.

Breaking Down the Command

chmod

Stands for Change Mode.


Used to change the permissions of a file or directory.

u=rwx

u (Owner): Refers to the user (owner) of the file.


= (Set): Sets permissions for the owner.
rwx: Grants read (r), write (w), and execute (x) permissions to the owner.
Effect: The owner can read, modify, and execute the file.

g+x

g (Group): Refers to the group associated with the file.


+x: Adds execute (x) permission to the group.
Effect: The group gains execute permission, but other existing permissions (e.g., read)
remain unchanged.

o=

o (Others): Refers to all other users not in the owner or group.


= (Set): Sets permissions for others.
= (Empty): Removes all permissions for others.
Effect: Others can no longer read, write, or execute the file.

linuxclass.txt

Specifies the file for which permissions are being modified.

Owner u (user) The user who owns the file.

Group g Users in the group


associated with the file.

Others o All other users who are not


the owner or group.

if you remember ugo, but you can just use numbers, they are easier

Breaking Down the Command

chmod

Stands for Change Mode.


Used to modify the permissions of a file or directory.

777- Read-4 write-2 xecute -1 (4+2+1=7)

The number 777 sets read (r), write (w), and execute (x) permissions for:
Owner (u) → Full permissions (rwx).
Group (g) → Full permissions (rwx).
Others (o) → Full permissions (rwx).

linuxclass.txt

Specifies the file whose permissions will be changed.

2. Understanding the Permissions

Numeric Representation:

777 consists of three digits, representing:


Owner (u): 7 → rwx (Read, Write, Execute).
Group (g): 7 → rwx (Read, Write, Execute).
Others (o): 7 → rwx (Read, Write, Execute).

What Happens:

Owner (u): Can read, write, and execute the file.


Group (g): Can read, write, and execute the file.
Others (o): Can read, write, and execute the file.

There are other commands like chown, chgrp- please go and read more

Commands to Check CPU Usage


and System Performance in Linux
top

Displays a real-time summary of system performance, including CPU usage, memory usage,
and running processes.
There are other commands as well, like ps -ef, df, proc e.t.c,
please read up and explore.

Understanding sudo, Creating a


User, and Assigning a Password
1. What Is sudo?

sudo (Superuser Do): A command that allows a regular user to run administrative tasks
(commands requiring root privileges).
It temporarily elevates the user’s permissions to execute restricted operations, such as
managing users or installing software.
Think of sudo as a keycard that lets you temporarily access restricted areas in a building.

Running a command with sudo:


Updates the package list (requires administrative rights). Some other tasks also requires
administrative rights, sometimes you get permission denied when you want to run some
commands, you can use sudo command to bypass this.

2. How to Create a New User


Command: adduser

The adduser command creates a new user with a home directory and prompts for a
password.

adduser username
Step 1: Attempt to Add a User Without Sudo

adduser gbadamosi

Result:
The command fails with the error: fatal: Only root may add a user or group to the system.
Why? Adding a user is an administrative task, so we need root privileges (via sudo).

Step 2: Adding the User With Sudo

sudo adduser gbadamosi

The sudo command is used to run adduser with elevated privileges.


The system performs the following steps:
1. Adding User and Group:
Creates a new user gbadamosi.
Automatically creates a group named gbadamosi with the same name as the user.
2. Assigning UID and GID:
Selects a UID (User ID) and GID (Group ID) for the user.
In this case, UID and GID are 1001.
3. Creating the Home Directory:
Creates a home directory for the user

Side note: if we check the /home, this user will be there


Step 3: Set the Password

Prompts you to set a password for the user:


New password: I typed the desired password(it does not display the password visibly).
Retype new password: Confirms the password.
Result: passwd: password updated successfully

Step 4: Provide User Information

Prompts for optional information:


Full Name: I entered Gbadamosi Adeniyi Temitope.
Room Number: I entered 2.
Work Phone, Home Phone, Other: I filled these with example numbers.
Press ENTER for fields you want to leave blank.
Confirms the details: Is the information correct? [Y/n] y

Step 5: Add the User to a Group

Automatically adds the user gbadamosi to a supplemental group called users:


info: Adding user 'gbadamosi' to group 'users' ...

To Switch to the new user:


su - username

type in the password you set

To view all the users

The command cat /etc/passwd displays all the users on the system. Each line in the file
represents a user account and contains several fields separated by colons (:). Let’s focus on the
Gbadamosi user entry and break it down field by field.
Breakdown of Gbadamosi's Entry

1. Username (gbadamosi)

This is the login name for the user. When I switch to this user or log in, I use gbadamosi.

2. Password Placeholder (x)

The x indicates that the encrypted password is stored in a separate file called /etc/shadow,
which is more secure than storing passwords directly in /etc/passwd.

3. User ID (UID: 1001)

Every user has a unique numerical identifier.


1001 is Gbadamosi's UID, used internally by the system to identify the user.
By convention:
UID 0: Root (superuser).
UID 1-999: Reserved for system users (e.g., services like syslog, mail).
UID 1000+: Regular user accounts.

4. Group ID (GID: 1001)


This is the numerical identifier for the user’s primary group.
The system automatically creates a group with the same name (gbadamosi) when the user is
added.
Groups are used to control permissions for shared files and resources.

5. User Info (GECOS: Gbadamosi Adeniyi Temitope,2,123456789,7888888,8888888)

This optional field stores additional information about the user in the following format:
mathematica
CopyEdit
Full Name,Room Number,Work Phone,Home Phone,Other
For Gbadamosi:
Full Name: Gbadamosi Adeniyi Temitope
Room Number: 2
Work Phone: 123456789
Home Phone: 7888888
Other: 8888888

6. Home Directory (/home/gbadamosi)

The user’s personal directory where their files, configurations, and settings are stored.
When Gbadamosi logs in, this is the default directory.

7. Login Shell (/bin/bash)

Specifies the default shell assigned to the user.


For Gbadamosi, the shell is /bin/bash (Bourne Again Shell), which is the most common shell
used for Linux.

Package Management
What Is Package Management?

Package managers are tools that automate the process of installing, upgrading, configuring,
and removing software on Linux systems. it is like an app store for Linux, but everything
runs in the terminal.

Package management simplifies the installation, updating, and removal of software in Linux. It
eliminates the need to manually download and configure software from the internet.

Key Concepts:

1. Repositories:
Centralized locations where software packages are stored.
The package manager fetches software from these repositories.
2. APT (Advanced Package Tool):
The package manager for Debian-based systems (like Ubuntu).
Used to install, update, and manage software packages.
3. Commands:
install: Installs a package.
update: Updates the list of available packages.
upgrade: Upgrades installed packages to newer versions.

for example, let’s say we need maven, what is maven? Apache Maven is a build automation
tool primarily used for Java-based projects. It manages:

Project building: Compiling the source code into executable files.


Dependencies: Downloading and including external libraries required by your project.
Project lifecycle: Automates repetitive tasks like testing and packaging.

Now we needed maven and we checked for it using command maven --version or mvn --version,
it says not found because maven is not yet installed.

The error Command 'maven' not found indicates that Maven is not installed on the system.
The system suggests using a package manager (sudo apt install) to install it.

Steps to Install Maven Using APT


Step 1

What It Does: Refreshes the list of available software in your system’s repositories.

Think of it as syncing your "App Store" with the latest catalog.


Step 2: Install Maven

Press y to continue, However, if i had done sudo apt install maven -y it would have installed it
automatically without asking any questions.

Step 3: Confirm the installation

After the installation using our package manager (sudo apt install), we see maven successfully
installed.

Popular Package Managers by Distribution

1. apt (Ubuntu, Debian, Linux Mint)


Command: sudo apt install <package>
2. yum (CentOS, RHEL - older versions)
Command: sudo yum install <package>
3. dnf (Fedora, CentOS Stream, RHEL - newer versions)
Command: sudo dnf install <package>

The linux distro I chose for this project was Ubuntu, hence the reason we used sudo apt install

Final Notes

Phew! It’s been a ride! This guide is an introduction (an incredibly detailed one) to get you
started on grasping Linux commands, a vital skill for DevOps and DevSecOps.

Remember, this is just the beginning. There are so many more commands and concepts waiting
for you to explore. Research, practice, and keep building on what you’ve learned.

As I always say: people can only give you 50% at best, but you have to bring your own 50% to
make it 100%.

If you have questions or need clarification, feel free to reach out to me on LinkedIn at Temitope
Adeniyi Gbadamosi.

You’ve got this! Relax, practice, give yourself some time, and allow plenty of grace as you learn.
Wishing you all the best on your journey!

You might also like