0% found this document useful (0 votes)
39 views9 pages

Linux

Linux is a free and open-source operating system developed by Linus Torvalds, compatible with major hardware. It features a hierarchical file system where everything is treated as a file, and includes basic commands for navigation, file management, and user management. Key commands include `pwd`, `ls`, `cd`, `mkdir`, and `chmod`, which facilitate various operations within the system.

Uploaded by

bbhardwajtest
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)
39 views9 pages

Linux

Linux is a free and open-source operating system developed by Linus Torvalds, compatible with major hardware. It features a hierarchical file system where everything is treated as a file, and includes basic commands for navigation, file management, and user management. Key commands include `pwd`, `ls`, `cd`, `mkdir`, and `chmod`, which facilitate various operations within the system.

Uploaded by

bbhardwajtest
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/ 9

What is linux?

Linux is a free and open-source software operating system , which developed by linus torvalds.
It came from a unix family. it is compatibility with all major computer hardware such as x86 ,
ARM etc.

File System in Linux

In linux everything is represented as a file including a hardware program, the files are stored in a
directory , and every directory contains a file with a tree structure. That is called file system
hierarchy. Linux uses single rooted , inverted tree like structure. Root directory represents with /
(forward slash). it is a top-level directory in linux.

Basic command

1. The `pwd` command helps you identify your location in the file system :

`pwd` - Print Working Directory

pwd

2. The `ls` command is used to list the files and directories in the current directory :

`ls` - List Files and Directories

Command Description

ls <Path ` any define path` is define after `ls` command , it will display all contain of that
Name> location.

` -l ` flag is used to display the lists all contents with some extra information like
ls -l permission of the file or folder , time stamp.

ls – a ` -a ` flag is used to see the hidden files and folder.

3. The `uname` command retrieves system information:

uname - Print System Information

Note : By adding `-r ` flag to the `uname` command , you can display the kernal release
version.
uname -r Print Kernel Release Information

4. The `cd` command allows you to navigate the file system by changing your current directory.

cd - Change Directory

touch

The touch command is used to create a new empty file or update the timestamp of an existing
file.

touch new_file.txt

5. The `clear` command clears the terminal screen, providing a clean workspace.

clear - Clear the Terminal Screen

6. `whoami` returns the username of the current user logged into the terminal.

whoami - Display the Current User

7. `History` This command is used to display the history of the common that previously
executed. history

history

`free` This command is used to check the memory-related detail in your system.

free

`nslookup` is used to obtain information for DNS server. it stands for Name Server Lookup.

nslookup <domain name>

`ssh-keygen` is used to establish a secure SSH connection from your host machine to any
remote server. It generates a public/private key pair.

ssh-keygen -t rsa

`curl` is a tool which is used to fetch data and post the data over the internet. it can used
various of protocol like HTTPS , SMTP and FTP.

curl [options] [URL]

`curl -o `flag saves the data into a file on the local machine.

`curl -o [file_name] [URL...]

13. apt-get command used to manage packages in the linux. APT stand for the Advanced
Packaging Tool , and its main used of install , update , upgrade and remove the packages.

apt-get [options] command

14 . `du` command is used to check disk usage space.


du

15. `df` the is a command used to check the available disk space in system.

df -h

15. ifconfig is command is used to view the information about your network interface

ifconfig [OPTIONS] [INTERFACE]

Creating Files and Directories :

In DevOps, creating and managing files and directories is a common task. Here are some
essential commands :

1 . For creating a single directory:

mkdir GFG

2. For creating multiple directories:

mkdir GFG1 GFG2 GFG3

3. For creating directory paths (directories inside directories):

mkdir -p /GFG/GFG1/GFG2

4. For creating a series of numbered directories:

mkdir gfg{1..3}

Copying and Pasting Files and Directories:

The cp command is used for copying and pasting files or directories in Linux. Here are some
commonly used options and examples:

1 . For copying a file with verbosity and force (overwrite if necessary):

cp -rvf gfg1 gfg

Removing Files and Directories:

To delete files or directories in DevOps, you can use the rm command. Be cautious, as it
permanently removes data. Here’s an example:

For removing a directory and its contents:

rm -rvf gfg

Renaming Files and Directories

The mv command is used to rename files or directories. For example, to rename a directory
from “gfg” to “gfg-devops,” you can use:

mv gfg gfg-devops

ser Management

User management in Linux is a crucial aspect of DevOps and system administration. Managing
users and their permissions ensures that your systems are secure, organized, and meet the
needs of your organization. Here’s an overview of user management in Linux within a DevOps
context:

1 . Creating a User : To create a new user in Linux, you can use the useradd command. For
example:

sudo useradd [usernam]

2. Setting a Password: After creating a user, set a password using the passwd command:

sudo passwd [username]

3. Deleting a User: To delete a user, use the userdel command :

sudo userdel [username]

4. Switch to Another User: The su command allows you to switch to another user’s account by
providing the username as an argument. To exit from the user’s account and return to your
original session, you can simply type ‘exit’.

su [USER NAME]

5. Rename the User: To change the username from the current name (oldname) to the new
name (newname), use the following command.

sudo usermod -l [newname] [oldname]

Group Management :

A group is a collection of user accounts that is very use full to administrators for managing and
applying permission to a number users.

Command Description

sudo groupadd <groupname> Making a new group

sudo groupdel <groupname> delete the group

sudo usermod -g <groupname> <username> Adding a user to a group

Linux file system permission :

In linux , to increase the security of the file and directory. we need to used permission. There are
total three type of file permission are Read , Write , Execute.

There are three type of file permission are as follow:

• user ( u ) : Permissions used for the user of the file.

• group( g ) : Permission used by the group member.


• other (o) : Permission used by all other users.

For example, suppose a file has read permissions that are allowed for the user. In this case, the
user can only read that file, while the group and others will not be able to read it.

1 . `ls -ld` it is used to check the permission of directory

ls -ld

Permission Access for a file Access for a directory

display file contents and copy the


view contents of directory
Read (r) file

Write (w) modify the file contents modify the contents of a directory

execute the file if it an executable allow use of cd command to access


Execute (x) permission the directory

Permission with numeric & symbol

Number Permission Type Symbol

0 No permission —

1 Execute –x

2 Write -w-

3 Execute +Write -wx


Number Permission Type Symbol

4 Read r–

5 Read + Execute r-x

6 Read +Write rw-

7 Read + Write + Execute rwx

2. chmod This command is used to change the permission of file and directory.

chmod <permission of user , group , other> {filename }

3. chown : It is used to change the owner of the file and directory.

chown [owner_name] [file name]

4. cat : it is used to read and concatenate the text inside the files. with help of this command we
can displays the content inside the file.

cat <flag> {filename}


Command Description

cat -b This flag adds number to the text line.

cat -E This flag add $ at the end of each line.

5. Grep (Global Regular Expression Print) : It filter searches a file for a particular pattern of
characters , and displays all lines that contain the pattern.

grep <flag or search_word> {file name}

Command Description

grep -i Delivers results for case-insensitive strings.

grep -n Retrieve the corresponding strings and their respective line numbers.

grep -v Provides the output of lines that do not contain the search string.

ystem Information and Management

1. top

The top command displays real-time system resource usage, including CPU and memory. It’s
useful for monitoring system performance.

top

2. df

The df (Disk Free) command shows disk space usage for all mounted filesystems. It helps you
keep track of available storage.

df -h

3. free

The free command displays information about memory usage, including total, used, and free
memory.

free -h

Networking Commands

1. ping

The ping command tests network connectivity to a specific host. It’s useful for troubleshooting
network issues.
ping example.com

2. ifconfig or ip

These commands display network interface configuration. ifconfig is older and may be replaced
by ip.

ifconfig
OR
ip a

3. wget

The wget command downloads files from the internet. It’s helpful for retrieving files via HTTP,
HTTPS, or FTP.

wget http://example.com/file.zip

Package Management

1. apt-get (Debian/Ubuntu)

This command manages packages in Debian-based distributions, allowing you to install,


update, and remove software.

sudo apt-get install package_name

2. yum (CentOS/Fedora)

Similar to apt-get, yum manages packages in RPM-based distributions.

sudo yum install package_name

4). Basic Terminal Navigation Commands:

• ls : To get the list of all the files or folders.

• ls -l: Optional flags are added to ls to modify default behavior, listing contents in
extended form -l is used for “long” output

• ls -a: Lists of all files including the hidden files, add -a flag

• cd: Used to change the directory.

• du: Show disk usage.

• pwd: Show the present working directory.

• man: Used to show the manual of any command present in Linux.

• rmdir: It is used to delete a directory if it is empty.

• ln file1 file2: Creates a physical link.

• ln -s file1 file2: Creates a symbolic link.

• locate: It is used to locate a file in Linux System

• echo: This command helps us move some data, usually text into a file.
• df: It is used to see the available disk space in each of the partitions in your system.

• tar: Used to work with tarballs (or files compressed in a tarball archive)

5). File Permissions Commands: The chmod and chown commands are used to control
access to files in UNIX and Linux systems.

• chown : Used to change the owner of the file.

• chgrp : Used to change the group owner of the file.

• chmod : Used to modify the access/permission of a user.

You might also like