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

183 Basic Linux Commands For Beginners: Maczen Technologies

The command line is one of the nearly all well built trademarks of Linux. There exists an ocean of Linux commands, permitting you to do nearly everything you can be under the impression of doing on your Linux operating system. Although, this to the end of time creates a problem: by all of so copious commands accessible to manage, you don't comprehend where and at which point to fly learning them, especially when you are learner. If you are facing this problem, and are peering for a painless method to begin your command line journey in Linux, you've come to the right place, as in this article, we will launch you to a hold of well liked and helpful Linux commands.

Uploaded by

Anonymous VSdKP4
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views

183 Basic Linux Commands For Beginners: Maczen Technologies

The command line is one of the nearly all well built trademarks of Linux. There exists an ocean of Linux commands, permitting you to do nearly everything you can be under the impression of doing on your Linux operating system. Although, this to the end of time creates a problem: by all of so copious commands accessible to manage, you don't comprehend where and at which point to fly learning them, especially when you are learner. If you are facing this problem, and are peering for a painless method to begin your command line journey in Linux, you've come to the right place, as in this article, we will launch you to a hold of well liked and helpful Linux commands.

Uploaded by

Anonymous VSdKP4
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

183 Basic Linux Commands For Beginners

Maczen Technologies

Command Description

date date command is used to display the system date and time

cal cal command is used to display the calendar

date & cal date & cal command is used to display the system date, time and calendar

cal 8 2016 cal 8 2016 command is used to display the August month 2016 year calendar

clear clear command is used to clear the terminal window

exit exit command is used to exit from the terminal window

free free command is used to display the free and used system memory

free -b free -b command is used to display the free and used system memory in bytes

free -k free -k command is used to display the free and used system memory in kilobytes

free -m free -m command is used to display the free and used system memory in megabytes

passwd passwd command is used to change user password

date -- set 1998-11-02 date -- set 1998-11-02 command is used to set current date as 02 Nov 1988

date -- set 12:11:02 date -- set 12:11:02 command is used to set current time as 12:11:02 IST

df df command is used to display the disk usage

df -H df -H command is used to display the disk usage in gigabytes, megabytes, or kilobytes

shutdown shutdown command is used to power-off the machine

shutdown -h now shutdown -h now command is used to power-off the machine immediately

shutdown -h +10 shutdown -h +10 command is used to power-off the machine after 10 minutes

pwd pwd command is used to display the current directory

netstat -a netstat -a command is used to display all ports (both TCP and UDP)

netstat -at command is used to display only TCP (Transmission Control Protocol) port
netstat -at
connections

netstat -au command is used to display only UDP (User Datagram Protocol ) port
netstat -au
connections

netstat -I netstat -I command is used to display all active listening ports connections

netstat -It netstat -It command is used to display all active listening TCP ports

netstat -lu netstat -lu command is used to display all active listening UDP ports

netstat -lx netstat -lx command is used to display all active UNIX listening ports

ifconfig ifconfig command is used to display all the active interfaces details

ifconfig -a ifconfig -a command is used to display information of all network interfaces

cd cd command is used to change the current working directory


Command Description

man pwd man pwd command is used to display the manual for the pwd command

kill kill command is used to terminate processes without having to log out or reboot

du du command is used to display the information of disk usage of files and directories

ls ls command is used to list files & directories

ps ps command is used to report the process information

top top command is used to provide a quick overview of the currently running processes

mount mount command is used to view mounted file systems

uname uname command is used to report the name of the kernel

uname -v uname -v command is used to print the kernel version

uname -o uname -o command is used to print the name of the operating system

uname -m uname -m command is used to report the machine hardware name

uname --version uname --version command is used to print the version information and exit

uname -r uname -r command is used to print the kernel release

uname -n uname -n command is used to report the network node hostname

logname logname command is used to report the login name of the current user

whoami whoami command is used to print the name of the user

w command is used to report information about the users currently on the machine and
w
their processes

uptime uptime command is used to display how long the system has been running

who who command is used to display who is logged on

ifconfig command is used to view and change the configuration of the network interfaces on
ifconfig
the system

hostname -i hostname -i command is used to display the IP address of the hostname

last -1 username command is used to display when the user last logged on and off and
last -1 username
from where

last yourusername last yourusername command is used to list your last logins

du -a du -a command is used to display the size of each individual file

date -d fri date -d fri command is used to display What date is it this Friday

cal -y cal -y command is used to display current year's calendar

date --help date --help command is used to display the usage summary for the date command

service --status-all service --status-all command is used to check the status of all the services

service network status service network status command is used to check the status of the network services

service network start service network start command is used to start the network service

service network stop service network start command is used to stop the network service

service network restart service network start command is used to restart the network service

init 6 init 6 command is used to perform an immediate system reboot


Command Description

init 0 init 0 command is used to power-off the machine

echo $PWD echo $PWD command is used to print the current working directory

echo $OLDPWD echo $OLDPWD command is used to print the previous working directory

reset reset command is used to reset your terminal

!11 !11 command is used to execute the 11th command in command history

whereis ls whereis ls command is used to display where does ls command exists

date +%T date +%T command is used to display time in hh: mm: ss

nproc command is used to display the number of processing units available to the current
nproc
process

pstree command is used to display the information about running processes in the form of a
pstree
tree

arch arch command is used to print the machine's architecture

acpi command is used to display the information about the advanced configuration and
acpi
power Interface

hostid hostid command is used to display the host's numeric ID in hexadecimal format

lsusb lsusb command is used to list the USB devices

ls -lrt ls -lrt command is used to list the files by date

ss -tup ss -tup command is used to list the active connections to/from system

ss -tupl ss -tupl command is used to list the internet services on a system

lsblk command is used to report the information about storage devices such as hard disks,
lsblk
flash drives etc.

lspci command is used to report the information about usb ports, graphics cards, network
lspci
adapters etc.

sudo fdisk -l sudo fdisk -l command is used to display the information about file system partitions

sudo lshw command is used to display the information about hardware components such
sudo lshw
as cpu, disks, memory, usb controllers etc.

echo $? echo $? command is used to display the exit status of previous command

help help command is used to list the shell built-in commands

login login command is used to create a new session on the system

logout logout command is used to exit from the terminal window

fc-list fc-list command is used to display the list of available fonts

ncal ncal command is used to display the calendar

id command is used to display all the information about the current user (user id, username,
id
group id, group name etc.)

whatis ls whatis ls command is used to display a single line description about ls command

cal -3 cal -3 command is used to display last month, current month, and next month calendar

history history command is used to display the command history

sudo reboot sudo reboot command is used to power off or reboot the system
Command Description

ping google.com command is used to check the network connectivity between host (your
ping google.com
connection) and server (Google server)

useradd "lmartin" useradd "lmartin" command is used to create a new user named lmartin

passwd "lmartin" passwd "lmartin" command is used to assign password for user lmartin

passwd -d lmartin passwd -d lmartin command is used to disable password for user lmartin

info info command is used to list a few useful info commands

factor 20 factor 20 command is used to print the prime factors of the number 20

expr 1 + 2 expr 1 + 2 command is used to perform addition of two numbers 1 & 2

id lmartin command is used to display all the information about the user "lmartin" (user id,
id lmartin
username, group id, group name etc.)

mkdir files mkdir files command is used to create a new directory named files

rmdir files rmdir files command is used to remove the directory named files

mkdir myfiles files mkdir myfiles files command is used to create two directories named myfiles & files

ls -s ls -s command is used to list the size of files and directories

su root su root command is used to switch to the root user

rm -r * rm -r * command is used to delete every file and every directory

ls -X ls -X command is used to sort files and directories by extension name

rm test.php rm test.php command is used to remove the file named test.php

gzip test.php command is used to compress the file (test.php), so that it take up much less
gzip test.php
space

yum install httpd yum install httpd command is used to install apache in CentOS
apt install httpd apt install httpd command is used to install apache in Ubuntu

yum update httpd yum update httpd command is used to upgrade apache in CentOS
apt update httpd apt update httpd command is used to upgrade apache in Ubuntu

yum remove httpd yum update httpd command is used to uninstall apache in CentOS
apt remove httpd apt update httpd command is used to uninstall apache in Ubuntu

touch test.txt touch test.txt command is used to create a empty file named test.txt

tail test.html tail test.html command is used to print the last 10 lines from the file (test.html)

tail -n N test.html tail -n N test.html command is used to print N number of lines from the file (test.html)

cat test.html cat test.html command is used to examine the contents of the file (test.html)

diff test.html test.php command is used to compare the contents of files (test.html &
diff test.html test.php
test.php) line by line

comm test.html test.php command is used to compare two files (test.html & test.php) line by
comm test.html test.php
line

find test* command is used for searching files (test.txt, test.php, test.html, test.sql, test.js) in
find test*
a directory as well as in its sub-directories

cmp test.txt test.html command is used to perform byte-by-byte comparison of two files
cmp test.txt test.html
(test.txt & test.html)

printf 'Hello World' > test.txt command is used to create a file (test.txt) containing a text
printf 'Hello World' > test.txt
(Hello World)
Command Description

echo 'Hello World' > test.txt command is used to create a file (test.txt) containing a text
echo 'Hello World' > test.txt
(Hello World)

nl test.txt command is used to display the contents of a file (test.txt) and prepends each line
nl test.txt
with line number

stat test.txt stat test.txt command is used to display the detailed status of a file (test.txt)

gunzip test.php gunzip test.php command is used to uncompress the file (test.php) compressed by gzip

mv test.html text.html mv test.html text.html command is used to rename a file named test.html to text.html

cp test.html text.html command is used to copy the contents of test.html file to the text.html
cp test.html text.html
file. If the text.html file doesn't exist, then first it creates one and content is copied to it.

cat * > 0.txt command is used to append the contents of multiple files in a single directory
cat * > 0.txt
into one file (0.txt)

cat 1.txt 2.txt > 0.txt command is used to append the contents of files (1.txt & 2.txt) into one
cat 1.txt 2.txt > 0.txt
file (0.txt)

sed r 1.txt 2.txt 3.txt > 0.txt command is used to append the contents of files (1.txt, 2.txt &
sed r 1.txt 2.txt 3.txt > 0.txt
3.txt) into one file (0.txt)

sed h 1.txt 2.txt 3.txt > 0.txt command is used to append the contents of files (1.txt, 2.txt &
sed h 1.txt 2.txt 3.txt > 0.txt
3.txt) into one file (0.txt)

sed -n p 1.txt 2.txt 3.txt > sed -n p 1.txt 2.txt 3.txt > 0.txt command is used to append the contents of files (1.txt, 2.txt
0.txt & 3.txt) into one file (0.txt)

for i in {1..3}; do cat "$i.txt" for i in {1..3}; do cat "$i.txt" >> 0.txt; done command is used to append the contents of files
>> 0.txt; done (1.txt, 2.txt & 3.txt) into one file (0.txt) using for loop statement

less test.html less test.html command is used to view the contents of a file (test.html)

cksum test.txt command is used to print the CRC checksum and byte count for the file
cksum test.txt
(test.txt)

wc -w test.txt wc -w test.txt command is used to print the number of words in a text file (test.txt)

wc -m test.txt wc -m test.txt command is used to print the number of characters from a text file (test.txt)

wc -L test.txt wc -L test.txt command is used to print the length of the longest line in a file (test.txt)

vi vi command is used to open vi editor


i i command is used to go to insert mode
a =20; b =64; print (a + b); python program to add two numbers
Hit Escape to return to
Normal mode.
:w hello.py :w hello.py command is used to save text by name (hello.py)
:q :q command is used to quit the vi editor
python hello.py python hello.py command is used to execute the file (hello.py) to print the output: 84

:q! :q! command is used to quit the vi editor without saving the text

echo "Hello world!" >> 1.txt command is used to create a file (1.txt) containing a text (Hello
World)
echo "Hello world!" >> 1.txt echo "this is 2nd line text" >> 1.txt command is used to add a second line of text (this is 2nd
echo "this is 2nd line text" line text) to the file (1.txt)
>> 1.txt
echo "last line!" >> 1.txt echo "last line!" >> 1.txt command is used to add a third line of text (last line!) to the file
(1.txt)
Command Description

vi vi command is used to open vi editor


i i command is used to go to Insert mode
print "Hello World!"; Hello World Program in Perl
Hit Escape to return to
Normal mode.
:w hello.pl :w hello.pl command is used to save text by name (hello.pl)
:q :q command is used to quit the vi editor
perl hello.pl perl hello.pl command is used to execute the file (hello.pl) to print the output: Hello World!

vi vi command is used to open vi editor


i i command is used to go to Insert mode
echo Hello World Hello World Program in Shell Scripting
Hit Escape to return to
Normal mode.
:w hello.sh :w hello.sh command is used to save text by name (hello.sh)
:q :q command is used to quit the vi editor
sh hello.sh sh hello.sh command is used to execute the file (hello.sh) to print the output: Hello World

cd ../.. cd ../.. command takes you two folders back

cd - cd - command takes you to the previous working directory

grep hello 1.txt command is used to search a file (1.txt) for a particular pattern of characters
grep hello 1.txt
(hello) and displays the line that contain that pattern

grep -c hello 1.txt command is used to print only a count of the lines that match a pattern of
grep -c hello 1.txt
characters (hello)

userdel lmartin userdel lmartin command is used to delete a user named lmartin

getent passwd command is used to list all local users (with their login name, encrypted
getent passwd password, numerical user ID, numerical group ID, user home directory etc.)

compgen -u compgen -u command is used to list all local users

usermod -l martin lmartin command is used to change the name of the user from lmartin to
usermod -l martin lmartin
martin

sudo passwd lmartin sudo passwd lmartin command is used to change the password for a user (lmartin)

passwd -l lmartin passwd -l lmartin command is used to lock the password of a user (lmartin)

passwd -u lmartin passwd -u lmartin command is used to unlock the password of a user (lmartin)

wget wget http://website.com/files/1.txt command is used to download the file (1.txt) from the url
http://website.com/files/1.txt (http://website.com/files/1.txt)

mkdir files
cd files The following commands are used to create an empty file named 1.txt inside a directory
pwd named files
touch 1.txt

passwd -n 90 lmartin command is used to set 90 days for a user (lmartin) to change its
passwd -n 90 lmartin
password

passwd -S lmartin command is used to display password status information of a user


passwd -S lmartin
(lmartin)

echo $HOME echo $HOME command is used to display the path of the home directory

echo $PATH command is used to list which directories contain scripts for the command line
echo $PATH
to execute

chage -d 0 lmartin command is used to force immediate password expiration for the user
chage -d 0 lmartin
(lmartin)
Command Description

usermod -p "" lmartin command is used to assign a null password instead of an initial
usermod -p "" lmartin
password for the user (lmartin)

head 1.txt command is used to display the first 10 lines of the file (1.txt) to standard output
head 1.txt

last last command is used to show listing of last logged in users

eject eject command lets you eject removable media (typically, a CD ROM or floppy disk)

paste -s 1.txt paste -s 1.txt command is used to join all the lines of the file (1.txt)

which date command is used to locate the executable file associated with the date
which date
command

yes linux yes linux command outputs a string (linux) repeatedly until killed

time df command is used to display the disk usage and report how long it took for df
time df
command to execute

sleep 10 command is used to make your terminal pause for 10 seconds before returning
sleep 10
you to the command line

sleep 20s command is used to make your terminal pause for 20 seconds before returning
sleep 20s
you to the command line

sleep 1m command is used to make your terminal pause for 1 minute before returning you
sleep 1m
to the command line

sleep 2h command is used to make your terminal pause for 2 hours before returning you to
sleep 2h
the command line

sleep 2d command is used to make your terminal pause for 2 days before returning you to
sleep 2d
the command line

shutdown -c shutdown -c command is used to cancel running shutdown

shutdown -h 18:00 shutdown -h 18:00 command is used to power-off the machine at 6PM

userdel -r lmartin userdel -r lmartin command is used to delete user (lmartin) with home directory

du -sh 1.txt du -sh 1.txt command is used to display the information of disk usage of file (1.txt)

ls -a ls -a command is used to display hidden file

sudo dmidecode -t 16 command is used to display the maximum RAM supported by the
sudo dmidecode -t 16
system

head -5 1.txt head -5 1.txt command is used to display the first 5 lines of the file (1.txt) to standard output

uniq 2.txt uniq 2.txt command is used to report or even delete repeated lines in a file (2.txt)

uniq -c 2.txt command is used to output the number of times a line is repeated in a file
uniq -c 2.txt
(2.txt)

zcat 2.txt.gz command is used to display the content of the gzip compressed text file
zcat 2.txt.gz
(2.txt.gz)

You might also like