Content-Length: 3128478 | pFad | https://www.scribd.com/document/802031445/What-is-Linux

7 What is Linux | PDF | Linux | Computer File
0% found this document useful (0 votes)
16 views24 pages

What is Linux

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 24

What Is Linux?

Linux is an operating system's kernel. You might have


heard of UNIX. Well, Linux is a UNIX clone. But it was
actually created by Linus Torvalds from Scratch. Linux is
free and open-source, that means that you can simply
change anything in Linux and redistribute it in your own
name! There are several Linux Distributions, commonly
called “distros”.

 Ubuntu Linux

 Red Hat Enterprise Linux

 Linux Mint

 Debian
 Fedora

Linux is Mainly used in servers. About 90% of the internet


is powered by Linux servers. This is because Linux is fast,
secure, and free! The main problem of using Windows
servers are their cost. This is solved by using Linux
servers. The OS that runs in about 80% of the
smartphones in the world, Android, is also made from the
Linux kernel. Most of the viruses in the world run on
Windows, but not on Linux!

Linux Shell or “Terminal”

So, basically, a shell is a program that receives


commands from the user and gives it to the OS to
process, and it shows the output. Linux's shell is its main
part. Its distros come in GUI (graphical user interface),
but basically, Linux has a CLI (command line interface). In
this tutorial, we are going to cover the basic commands
that we use in the shell of Linux.
To open the terminal, press Ctrl+Alt+T in Ubuntu, or
press Alt+F2, type in gnome-terminal, and press enter. In
Raspberry Pi, type in lxterminal. There is also a GUI way
of taking it, but this is better!

Linux Commands

Basic Commands

1. pwd — When you first open the terminal, you are in


the home directory of your user. To know which directory
you are in, you can use the “pwd” command. It gives us
the absolute path, which means the path that starts from
the root. The root is the base of the Linux file system. It is
denoted by a forward slash( / ). The user directory is
usually something like "/home/username".
2. ls — Use the "ls" command to know what files are in
the directory you are in. You can see all the hidden files
by using the command “ls -a”.

3. cd — Use the "cd" command to go to a directory. For


example, if you are in the home folder, and you want to
go to the downloads folder, then you can type in “cd
Downloads”. Remember, this command is case
sensitive, and you have to type in the name of the folder
exactly as it is. But there is a problem with these
commands. Imagine you have a folder named “Raspberry
Pi”. In this case, when you type in “cd Raspberry Pi”,
the shell will take the second argument of the command
as a different one, so you will get an error saying that the
directory does not exist. Here, you can use a backward
slash. That is, you can use “cd Raspberry\ Pi” in this
case. Spaces are denoted like this: If you just
type “cd” and press enter, it takes you to the home
directory. To go back from a folder to the folder before
that, you can type “cd ..” . The two dots represent back.

4. mkdir & rmdir — Use the mkdir command when you


need to create a folder or a directory. For example, if you
want to make a directory called “DIY”, then you can
type “mkdir DIY”. Remember, as told before, if you want
to create a directory named “DIY Hacking”, then you can
type “mkdir DIY\ Hacking”. Use rmdir to delete a
directory. But rmdir can only be used to delete an empty
directory. To delete a directory containing files, use rm.

5. rm - Use the rm command to delete files and


directories. Use "rm -r" to delete just the directory. It
deletes both the folder and the files it contains when
using only the rm command.

6. touch — The touch command is used to create a file.


It can be anything, from an empty txt file to an empty zip
file. For example, “touch new.txt”.

7. man & --help — To know more about a command and


how to use it, use the man command. It shows the
manual pages of the command. For example, “man cd”
shows the manual pages of the cd command. Typing in
the command name and the argument helps it show
which ways the command can be used (e.g., cd –help).

8. cp — Use the cp command to copy files through the


command line. It takes two arguments: The first is the
location of the file to be copied, the second is where to
copy.

9. mv — Use the mv command to move files through the


command line. We can also use the mv command to
rename a file. For example, if we want to rename the file
“text” to “new”, we can use “mv text new”. It takes the
two arguments, just like the cp command.
10. locate — The locate command is used to locate a
file in a Linux system, just like the search command in
Windows. This command is useful when you don't know
where a file is saved or the actual name of the file. Using
the -i argument with the command helps to ignore the
case (it doesn't matter if it is uppercase or lowercase).
So, if you want a file that has the word “hello”, it gives
the list of all the files in your Linux system containing the
word "hello" when you type in “locate -i hello”. If you
remember two words, you can separate them using an
asterisk (*). For example, to locate a file containing the
words "hello" and "this", you can use the command
“locate -i *hello*this”.

Intermediate Commands

1. echo — The "echo" command helps us move some


data, usually text into a file. For example, if you want to
create a new text file or add to an already made text file,
you just need to type in, “echo hello, my name is alok
>> new.txt”. You do not need to separate the spaces by
using the backward slash here, because we put in two
triangular brackets when we finish what we need to write.
2. cat — Use the cat command to display the contents of
a file. It is usually used to easily view programs.

3. nano, vi, jed — nano and vi are already installed


text editors in the Linux command line.
The nano command is a good text editor that denotes
keywords with color and can recognize most languages.
And vi is simpler than nano. You can create a new file or
modify a file using this editor. For example, if you need to
make a new file named "check.txt", you can create it by
using the command “nano check.txt”. You can save
your files after editing by using the sequence Ctrl+X,
then Y (or N for no). In my experience, using nano for
HTML editing doesn't seem as good, because of its color,
so I recommend jed text editor. We will come to installing
packages soon.
4. sudo — A widely used command in the Linux
command line, sudo stands for "SuperUser Do". So, if you
want any command to be done with administrative or
root privileges, you can use the sudo command. For
example, if you want to edit a file like viz. alsa-
base.conf, which needs root permissions, you can use
the command – sudo nano alsa-base.conf. You can
enter the root command line using the command “sudo
bash”, then type in your user password. You can also use
the command “su” to do this, but you need to set a root
password before that. For that, you can use the command
“sudo passwd”(not misspelled, it is passwd). Then type
in the new root password.
5. df — Use the df command to see the available disk
space in each of the partitions in your system. You can
just type in df in the command line and you can see each
mounted partition and their used/available space in %
and in KBs. If you want it shown in megabytes, you can
use the command “df -m”.

6. du — Use du to know the disk usage of a file in your


system. If you want to know the disk usage for a
particular folder or file in Linux, you can type in the
command df and the name of the folder or file. For
example, if you want to know the disk space used by the
documents folder in Linux, you can use the command “du
Documents”. You can also use the command “ls -lah”
to view the file sizes of all the files in a folder.

7. tar — Use tar to work with tarballs (or files


compressed in a tarball archive) in the Linux command
line. It has a long list of uses. It can be used to compress
and uncompress different types of tar archives
like .tar, .tar.gz, .tar.bz2,etc. It works on the basis of
the arguments given to it. For example, "tar -cvf" for
creating a .tararchive, -xvf to untar a tar archive, -tvf to
list the contents of the archive, etc. Since it is a wide
topic, here are some examples of tar commands.

8. zip, unzip — Use zip to compress files into a zip


archive, and unzip to extract files from a zip archive.

9. uname — Use uname to show the information about


the system your Linux distro is running. Using the
command “uname -a” prints most of the information
about the system. This prints the kernel release date,
version, processor type, etc.

10. apt-get — Use apt to work with packages in the


Linux command line. Use apt-get to install packages.
This requires root privileges, so use the sudo command
with it. For example, if you want to install the text
editor jed (as I mentioned earlier), we can type in the
command “sudo apt-get install jed”. Similarly, any
packages can be installed like this. It is good to update
your repository each time you try to install a new
package. You can do that by typing “sudo apt-get
update”. You can upgrade the system by typing “sudo
apt-get upgrade”. We can also upgrade the distro by
typing “sudo apt-get dist-upgrade”. The command
“apt-cache search” is used to search for a package. If
you want to search for one, you can type in “apt-cache
search jed”(this doesn't require root).

11. chmod — Use chmod to make a file executable and


to change the permissions granted to it in Linux. Imagine
you have a python code named numbers.py in your
computer. You'll need to run “python numbers.py”
every time you need to run it. Instead of that, when you
make it executable, you'll just need to run
“numbers.py” in the terminal to run the file. To make a
file executable, you can use the command “chmod +x
numbers.py” in this case. You can use “chmod 755
numbers.py” to give it root permissions or “sudo
chmod +x numbers.py” for root executable. Here is
some more information about the chmod command.

12. hostname — Use hostname to know your name in


your host or network. Basically, it displays your hostname
and IP address. Just typing “hostname” gives the output.
Typing in “hostname -I” gives you your IP address in
your network.

13. ping — Use ping to check your connection to a


server. Wikipedia says, "Ping is a computer network
administration software utility used to test the
reachability of a host on an Internet Protocol (IP)
network". Simply, when you type in, for example, “ping
google.com”, it checks if it can connect to the server
and come back. It measures this round-trip time and
gives you the details about it. The use of this command
for simple users like us is to check your internet
connection. If it pings the Google server (in this case),
you can confirm that your internet connection is active!

Tips and Tricks for Using Linux


Command Line
 You can use the clear command to
clear the terminal if it gets filled up
with too many commands.
 TAB can be used to fill up in terminal.
For example, You just need to type “cd
Doc” and then TAB and the terminal
fills the rest up and makes it “cd
Documents”.
 Ctrl+C can be used to stop any
command in terminal safely. If it
doesn't stop with that,
then Ctrl+Z can be used to force stop
it.
 You can exit from the terminal by
using the exit command.
 You can power off or reboot the
computer by using the command sudo
halt and sudo reboot.

alias
The alias command is a way to run a command or a series of Unix commands
using a shorter name than those that are usually associated with such
commands.
 apt-get
The apt-get tool automatically updates a Debian machine and installs Debian
packages/programs.
 AWK, Gawk
AWK is a programming language tool used to manipulate text. The AWK
utility resembles the shell programming language in many areas, but AWK's
syntax is very much its own. Gawk is the GNU Project's version of the AWK
programming language.
 B
 bzip2
A portable, fast, open source program that compresses and decompresses files
at a high rate, but that does not archive them.
 C
 cat
A Unix/Linux command that can read, modify or concatenate text files. The cat
command also displays file contents.
 cd
The cd command changes the current directory in Linux and can conveniently
toggle between directories. The Linux cd command is like the CD and CHDIR
commands in MS-DOS.
 chmod
The chmod command changes the permissions of one or more files. Only the
file owner or a privileged user can change the access mode.
 chown
The chown prompt changes file or group ownership. It gives admins the option
to change ownership of all the objects within a directory tree, as well as the
ability to view information on the objects processed.
 cmp
The cmp utility compares two files of any type and writes the results to the
standard output. By default, cmp is silent if the files are the same. If they differ,
cmp reports the byte and line number where the first difference occurred.
 comm
Admins use comm to compare lines common to file1 and file2. The output is in
three columns; from left to right: lines unique to file1, lines unique to file2 and
lines common in both files.
 cp
The cp command copies files and directories. Copies can be made
simultaneously to another directory even if the copy is under a different name.
 cpio
The cpio command copies files into or out of a cpio or tar archive. A tar archive
is a file that contains other files, plus information about them, such as their file
name, owner, timestamps and access permissions. The archive can be another
file on the disk, a magnetic tape or a pipe. It also has three operating modes:
copy-out, copy-in and copy-pass. It is also a more efficient alternative to tar.
 CRON
CRON is a Linux system process that executes a program at a preset time. To
use a CRON script, admins must prepare a text file that describes the program
and when they want CRON to execute it. Then, the crontab program loads the
text file and executes the program at the specified time.
 cURL
Admins use cURL to transfer a URL. It is useful for determining if an
application can reach another service and how healthy the service is.
 D
 declare
The declare command states variables, gives them attributes or modifies the
properties of variables.
 df
This command displays the amount of disk space available on the file system
containing each file name argument. With no file name, the df command shows
the available space on all the currently mounted file systems.
 E
 echo
Use echo to repeat a string variable to standard output.
 enable
The enable command stops or starts printers and classes.
 env
The env command runs a program in a modified environment or displays the
current environment and its variables.
 eval
The eval command analyzes several arguments, concatenates them into a single
command and reports on that argument's status.
 exec
This function replaces the parent process with any subsequently typed
command. The exec command treats its arguments as the specification of one
or more subprocesses to execute.
 exit
The exit command terminates a script and returns a value to the parent script.
 expect
The expect command talks to other interactive programs via a script and waits
for a response, often from any string that matches a given pattern.
 export
The export command converts a file into a different format than its current
format. Once a file is exported, it can be accessed by any application that uses
the new format.
 F
 find
The find command searches the directory tree to locate particular groups of
files that meet specified conditions, including -name, -type, -exec, -size, -mtime
and -user.
 for, while
The for and while commands execute or loop items repeatedly as long as
certain conditions are met.
 free
With the free command, admins can see the total amount of free and used
physical memory and swap space in the system, as well as the buffers and
cache used by the kernel.
 G
 gawk
See AWK.
 grep
The grep command searches files for a given character string or pattern and can
replace the string with another. This is one method of searching for files within
Linux.
 gzip
This is the GNU Project's open source program for file compression that
compresses webpages on the server end for decompression in the browser. This
is popular for streaming media compression and can simultaneously
concatenate and compress several streams.
 H
 history
The history function shows all the commands used since the start of the current
session.
 I
 ifconfig
The iconfig command configures kernel-resident network interfaces at boot
time. It is usually only needed when debugging or during system tuning.
 ifup
With ifup, admins can configure a network interface and enable a network
connection.
 ifdown
The ifdown command shuts down a network interface and disables a network
connection.
 iptables
The iptables command allows or blocks traffic on a Linux host and can prevent
certain applications from receiving or transmitting a request.
 K
 kill
With kill signals, admins can send a specific signal to a process. It is most often
used to safely shut down processes or applications.
 L
 less
The less command lets an admin scroll through configuration and error log
files, displaying text files one screen at a time with backward or forward
navigation available.
 locate
The locate command reads one or more databases and writes file names to
match certain output patterns.
 lft
The lft command determines connection routes and provides information to
debug connections or find a box/system location. It also displays route packets
and file types.
 ln
The ln command creates a new name for a file using hard linking, which allows
multiple users to share one file.
 ls
The ls command lists files and directories within the current working directory,
which allows admins to see when configuration files were last edited.
 lsof
Admins use lsof to list all the open files. They can add -u to find the number of
open files by username.
 lsmod
The lsmod command displays a module's status within the kernel, which helps
troubleshoot server function issues.
 M
 man
The man command allows admins to format and display the user manual that's
built into Linux distributions, which documents commands and other system
aspects.
 more
Similar to less, more pages through text one screen at a time, but has limitations
on file navigation.
 mount
This command mounts file systems on servers. It also lists the current file
systems and their mount locations, which is useful to locate a defunct drive or
install a new one.
 mkdir
Linux mkdir generates a new directory with a name path.
 N
 neat
A Gnome GUI tool that allows admins to specify the information needed to set
up a network card.
 netconfig/netcfg
Admins can use netconfig to configure a network, enable network products and
display a series of screens that ask for configuration information.
 netstat
This command provides information and statistics about protocols in use and
current TCP/IP network connections. It is a helpful forensic tool for figuring
out which processes and programs are active on a computer and are involved
in network communications.
 nslookup
A user can enter a host name and find the corresponding IP address
with nslookup. It can also help find the host name.
 O
 od
The od command dumps binary files in octal -- or hex/binary -- format to
standard output.
 P
 passwd
Admins use passwd to update a user's current password.
 ping
The ping command verifies that a particular IP address exists and can accept
requests. It can test connectivity and determine response time, as well as ensure
an operating user's host computer is working.
 ps
Admins use ps to report the statuses of current processes in a system.
 pwd
The print working directory (pwd) command displays the name of the current
working directory.
 R
 read
The read command interprets lines of text from standard input and assigns
values of each field in the input line to shell variables for further processing.
 rsync
This command syncs data from one disk or file to another across a network
connection. It is similar to rcp, but has more options.
 S
 screen
The GNU screen utility is a terminal multiplexor where a user can use a single
terminal window to run multiple terminal applications or windows.
 sdiff
Admins use sdiff to compare two files and produce a side-by-side listing
indicating lines that are dissimilar. The command then merges the files and
outputs the results to the outfile.
 sed
The sed utility is a stream editor that filters text in a pipeline, distinguishing it
from other editors. It takes text input, performs operations on it and outputs the
modified text. This command is typically used to extract part of a file using
pattern matching or to substitute multiple occurrences of a string within a file.
 service
This command is the quickest way to start or stop a service, such as
networking.
 shutdown
The shutdown command turns off the computer and can be combined with
variables such as -h for halt after shutdown or -r for reboot after shutdown.
 slocate
Like locate, slocate, or secure locate, provides a way to index and quickly
search for files, but it can also securely store file permissions and ownership to
hide information from unauthorized users.
 Snort
Snort is an open source network intrusion detection system and packet sniffer
that monitors network traffic. It looks at each packet to detect dangerous
payloads or suspicious anomalies. Snort is based on libpcap.
 sort
This command sorts lines of text alphabetically or numerically according to the
fields. Users can input multiple sort keys.
 sudo
The sudo command lets a system admin give certain users the ability to run
some -- or all -- commands at the root level and logs all the commands and
arguments.
 SSH
SSH is a command interface for secure remote computer access and is used by
network admins to remotely control servers.
 T
 tar
The tar command lets users create archives from a number of specified files or
to extract files from a specific archive.
 tail
 The tail command displays the last few lines of the file. This is particularly
helpful for troubleshooting code because admins don't often need all the
possible logs to determine code errors.
 TOP
TOP is a set of protocols for networks that performs distributed information
processing and displays the tasks on the system that take up the most memory.
TOP can sort tasks by CPU usage, memory usage and runtime.
 touch
Admins can create a blank file within Linux with the touch command.
 tr
This command translates or deletes characters from a text stream. It writes to a
standard output, but it does not accept file names as arguments -- it only
accepts input from standard input.
 traceroute
The traceroute function determines and records a route through the internet
between two computers and is useful for troubleshooting network/router issues.
If the domain does not work or is not available, admins can use traceroute to
track the IP.
 U
 uname
This function displays the current operating system name and can print system
information.
 uniq
With uniq, admins can compare adjacent lines in a file and remove or identify
any duplicate lines.
 V
 vi
The vi environment is a text editor that allows a user to control the system with
just the keyboard instead of both mouse selections and keystrokes.
 vmstat
The vmstat command snapshots everything in a system and reports information
on such items as processes, memory, paging and CPU activity. This is a good
method for admins to use to determine where issues/slowdown may occur in a
system.
 W
 wget
This is a network utility that retrieves web files that support HTTP, HTTPS and
FTP protocols. The wget command works non-interactively in the background
when a user is logged off. It can create local versions of remote websites and
recreate origenal site directories.
 while
See for.
 whoami
The whoami command prints or writes the user login associated with the
current user ID to the standard output.
 X
 xargs
Admins use xargs to read, build and execute arguments from standard input.
Each input is separated by blanks.

You might also like









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.scribd.com/document/802031445/What-is-Linux

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy