0% found this document useful (0 votes)
10 views16 pages

Basic Linux Commands - Amazon Wiki

The document provides a comprehensive guide on basic Linux commands useful for Amazon FC Support Technicians, including commands for moving, copying, deleting files, and managing packages. It includes examples and options for commands like mv, grep, cp, rm, pwd, uptime, rsync, ssh, rpm, and fdisk. Each command is explained with syntax, useful options, and practical examples to assist users in navigating the Linux environment effectively.

Uploaded by

ahmed ibrahim
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)
10 views16 pages

Basic Linux Commands - Amazon Wiki

The document provides a comprehensive guide on basic Linux commands useful for Amazon FC Support Technicians, including commands for moving, copying, deleting files, and managing packages. It includes examples and options for commands like mv, grep, cp, rm, pwd, uptime, rsync, ssh, rpm, and fdisk. Each command is explained with syntax, useful options, and practical examples to assist users in navigating the Linux environment effectively.

Uploaded by

ahmed ibrahim
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

Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.

php/Basic_Linux_Commands#mv

Basic Linux Commands Amazon Con$idential


Amazon Con$idential

This page provide a list of useful commands and examples of their use within the Amazon
environment for training FC Support Technicians.

Note: Remember that on most systems you can read the manual
for all the details and parameters of the command you are
interested in:

man <command>

mv
The linux command for moving a $ile, also used for renaming a $ile.

mv /<path>/<from> /<path>/<to>

Useful Options
-f force (Do not prompt when overwriting $iles)
-i interactive (Asks if you want to overwrite $iles)
-v verbose (Expand on what was action was performed)

Example
To move the $ile day.txt to the /home/Training folder you do the following:

# mv -vf day.txt /home/Training/


`day.txt' -> `Training/day.txt'

grep
grep <word> <path>/<$ile>

Useful Options
-f <$ile> read one or more patterns from the $ile
-i case insensitive (ignore the case of the word you are searching for).

1 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

-v invert match (eveything other than the word speci$ied)


-n line numbers (output with line numbers).
-s suppress (suppress error messages regarding unreadable $iles).

Example
If we have a text $ile called mac-address.txt stored in /home containing a list of MAC addresses:

00:11:85:61:87:5a Julies Polycom


00:04:f2:51:65:5d Aarons PC
00:21:85:5f:38:05 Andys Laptop
00:31:22:01:82:26 andys PC

We could search it for a particular MAC address using:

# grep 00:11:85:61:87:5a /home/mac-address.txt


00:11:85:61:87:5a Julies Polycom

Or we can exclude Andys devices from the list we can just use the -v and -i options:

# grep -vi Andy /home/mac-addresses.txt


00:11:85:61:87:5a Julies Polycom
00:04:f2:51:65:5d Aarons PC

cp
The linux command to copy a $ile.

cp /<path>/<from> /<path>/<to>

Useful Options
-i interactive (Asks if you want to overwrite $iles)
-v verbose (Expand on what was action was performed)
-r recursive (Copy sub directories and $iles also)

Example
To copy a directory and all its $iles and sub directories you use the following command:

# cp -r /home/important_notes /home/copy_of_important_notes

rm
rm stands for remove and is the linux command for deleting $iles.

rm /<path>/<$ilename>

2 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

Useful Options:
-i Interactive, asks you to con$irm each $ile being deleted.

Example:

# rm /home/important_notes

pwd
pwd prints the current working directory.

Example:
If you change directory (cd) to /var/log and type pwd:

# pwd
/var/log

uptime
This command tells you the current time, length of time the host has been running (days then
hours:minutes:seconds), numbers of users currently logged on, and the load averages for the past 1,
5, and 15 minutes.

Example:

# uptime
13:47:33 up 5 days, 3:09, 7 users, load average: 0.65, 0.36,
0.18

Note: Go here (http://en.wikipedia.org/wiki/Load_(computing)) an explanation of load averages.

rsync
The rsync command is useful as a $ile transfer or backup tool.

Useful Options:
-r recurse into directories
-v increase verbosity
-p preserve permissions
--links Recreate the symlink on the destination
--bwlimit=KBPS limit I/O bandwidth (KBytes per second)
--rsh=ssh remote shell (ssh is preferred at its a secure shell)

Examples: If you run the following command on server1, rsync will synchronise the all the $iles on

3 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

server1 in /mnt/backup with server 2's $iles in /home/england keeping the permissions the same,
and limiting the speed to 500MBytes per second:

rsync --links -rvp --bwlimit=512000 --rsh=ssh england@server2:/home


/england /mnt/backup/

To perform a local backup, which only copies the $iles that have changed since the previous backup,
you can use the following:

rsync -avzhr /home/england /mnt/backup/

ssh
ssh stands for secure shell. For those familiar with telnet, you can think of this in exactly the same
way, except its encrypted.

ssh <username>@<hostname>

Useful Options:
-p port (So you can connect to a port other than ssh's normal port 22)
-v Verbose (print debugging messages).

Examples:

# ssh fc-login-gla1-101.gla1.amazon.com
Password:
Last login: Tue May 27 16:48:23 2008 from 10.67.9.206
#
--------------------------------------------------------------------
----------
[amazon]

Description:
This system is for amazon.com authorized use only, and is monitored
to detect improper use and other illicit activity.

#
--------------------------------------------------------------------
----------
Rebooted at 20:15PM 08/18/07 2.4.21-37a6smp
Rebooted at 03:22AM 09/30/07 2.4.21-37a6smp
Rebooted at 00:30AM 10/07/07 2.4.21-37a6smp
SWITCH eth0: gla1-co-acc-sw101.amazon.com GigabitEthernet1/0/41
england@login-gla1-101[gb-gla1]>

4 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

rpm
The rpm command is used to install, query and remove software installed using Red Hat Package
Management on Linux distributions including SUSE, OpenSUSE, Mandriva, Fedora, CENTOS and of
course Red Hat.

Examples:
To install the package gip-1.6.1.1-1.fc7.rf.i386.rpm:

# rpm -ivh gip-1.6.1.1-1.fc7.rf.i386.rpm


warning: gip-1.6.1.1-1.fc7.rf.i386.rpm: Header V3 DSA signature:
NOKEY, key ID 1aa78495
Preparing...
########################################### [100%]
1:gip
########################################### [100%]

To erase or remove the package gip-1.6.1.1-1.fc7.rf.i386.rpm:

# rpm -ivh gip

What $iles are included in the the package gip:

# rpm -ql gip


/usr/bin/gip
/usr/share/applications/rpmforge-gip.desktop
/usr/share/doc/gip-1.6.1.1
/usr/share/doc/gip-1.6.1.1/AUTHORS
/usr/share/doc/gip-1.6.1.1/CHANGELOG
/usr/share/doc/gip-1.6.1.1/COPYING
/usr/share/doc/gip-1.6.1.1/INSTALL
/usr/share/doc/gip-1.6.1.1/README
/usr/share/gip
/usr/share/gip/calculator.png
/usr/share/gip/gears.png
...

To show general info on a package openssh:

# rpm -qi openssh


Name : openssh Relocations: (not
relocatable)
Version : 5.0p1 Vendor: Fedora
Project
Release : 1.fc9 Build Date: Mon 07 Apr

5 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

2008 21:24:03 BST


Install Date: Thu 08 May 2008 02:41:17 BST Build Host:
xenbuilder4.fedora.phx.redhat.com
Group : Applications/Internet Source RPM: openssh-
5.0p1-1.fc9.src.rpm
Size : 779002 License: BSD
Signature : DSA/SHA1, Fri 11 Apr 2008 15:44:25 BST, Key ID
b44269d04f2a6fd2
Packager : Fedora Project
URL : http://www.openssh.com/portable.html
Summary : The OpenSSH implementation of SSH protocol versions 1
and 2
Description :
SSH (Secure SHell) is a program for logging into and executing
commands on a remote machine. SSH is intended to replace rlogin and
...

What package owns /etc/samba/smbusers:

# rpm -qf /etc/samba/smbusers


samba-3.2.0-1.rc1.14.fc9.i386

What are the con$ig $iles in the httpd package:

# rpm -qc httpd


/etc/httpd/conf.d/proxy_ajp.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/httpd
/var/www/error/HTTP_BAD_GATEWAY.html.var
...

fdisk
fdisk is a partitioning tool similar to the old FDISK.EXE tool for DOS/Windows.

fdisk /dev/<disk device>

Useful Commands:

m list of commands and actions


p print the partition table
n create a new partition
d delete a partition
q quit without saving changes

6 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

w write the new partition table and exit


l list known partition types

Examples:

sudo /sbin/fdisk /dev/sda

The number of cylinders for this disk is set to 5169.


There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

For a new hard disk running p command will show something like this:

Disk /dev/sda: 40.0 GB, 40020664320 bytes


240 heads, 63 sectors/track, 5169 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0x95189518

Device Boot Start End Blocks Id System

To create a 100MB boot partition we can do the following:

Command (m for help): n


Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-5169, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-5169, default 5169):
+100M

Command (m for help): p

Disk /dev/sda: 40.0 GB, 40020664320 bytes


240 heads, 63 sectors/track, 5169 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0x95189518

Device Boot Start End Blocks Id System


/dev/sda1 1 14 105808+ 83 Linux

7 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

To make the /boot partition bootable we need to do the following:

Command (m for help): a


Partition number (1-4): 1

Command (m for help): p

Disk /dev/sda: 40.0 GB, 40020664320 bytes


240 heads, 63 sectors/track, 5169 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0x95189518

Device Boot Start End Blocks Id System


/dev/sda1 * 1 14 105808+ 83 Linux
/dev/sda2 15 1307 9775080 83 Linux
/dev/sda3 1308 1373 498960 82 Linux swap /
Solaris

Now we need to create a root partition of 10000MB (10GB):

Command (m for help): n


Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (15-5169, default 15):
Using default value 15
Last cylinder or +size or +sizeM or +sizeK (15-5169, default 5169):
+10000M

Command (m for help): p

Disk /dev/sda: 40.0 GB, 40020664320 bytes


240 heads, 63 sectors/track, 5169 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0x95189518

Device Boot Start End Blocks Id System


/dev/sda1 1 14 105808+ 83 Linux
/dev/sda2 15 1307 9775080 83 Linux

Now we need to create a swap space partition of 500MB:

Command (m for help): n


Command action
e extended

8 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

p primary partition (1-4)


p
Partition number (1-4): 3
First cylinder (1308-5169, default 1308):
Using default value 1308
Last cylinder or +size or +sizeM or +sizeK (1308-5169, default
5169): +500M

Command (m for help): p

Disk /dev/sda: 40.0 GB, 40020664320 bytes


240 heads, 63 sectors/track, 5169 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0x95189518

Device Boot Start End Blocks Id System


/dev/sda1 1 14 105808+ 83 Linux
/dev/sda2 15 1307 9775080 83 Linux
/dev/sda3 1308 1373 498960 83 Linux

Command (m for help): t


Partition number (1-4): 3
Hex code (type L to list codes): 82
Changed system type of partition 3 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sda: 40.0 GB, 40020664320 bytes


240 heads, 63 sectors/track, 5169 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0x95189518

Device Boot Start End Blocks Id System


/dev/sda1 1 14 105808+ 83 Linux
/dev/sda2 15 1307 9775080 83 Linux
/dev/sda3 1308 1373 498960 82 Linux swap /
Solaris

Now we need a partition for /home (when asked for $irst and last cylinder I just hit enter which
accepts the defaults fdisk suggests):

Command (m for help): n


Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (1374-5169, default 1374):
Using default value 1374
Last cylinder or +size or +sizeM or +sizeK (1374-5169, default

9 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

5169):
Using default value 5169

Command (m for help): p

Disk /dev/sda: 40.0 GB, 40020664320 bytes


240 heads, 63 sectors/track, 5169 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0x95189518

Device Boot Start End Blocks Id System


/dev/sda1 * 1 14 105808+ 83 Linux
/dev/sda2 15 1307 9775080 83 Linux
/dev/sda3 1308 1373 498960 82 Linux swap /
Solaris
/dev/sda4 1374 5169 28697760 5 Extended

Command (m for help): n


First cylinder (1374-5169, default 1374):
Using default value 1374
Last cylinder or +size or +sizeM or +sizeK (1374-5169, default
5169):
Using default value 5169

Command (m for help): p

Disk /dev/sda: 40.0 GB, 40020664320 bytes


240 heads, 63 sectors/track, 5169 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0x95189518

Device Boot Start End Blocks Id System


/dev/sda1 * 1 14 105808+ 83 Linux
/dev/sda2 15 1307 9775080 83 Linux
/dev/sda3 1308 1373 498960 82 Linux swap /
Solaris
/dev/sda4 1374 5169 28697760 5 Extended
/dev/sda5 1374 5169 28697728+ 83 Linux

Remember, once you have done this you will need to write the new partition table to disk by using the
w command.

External Link:

http://tldp.org/HOWTO/Partition/fdisk_partitioning.html

mke2fs
Now that we have created our partitions using fdisk, we can now format them using mke2fs (similar
to DOS/Windows format command). mke2fs can format partitions using either ext2 or ext3

10 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

$ilesystem. (ext2 - The second extended $ile system. ext3 -The third extended $ilesystem is a journaled
$ile system based on ext2).

mke2fs /dev/<disk device><partition>

Example Commands
To format /dev/sda1 as a ext2 $ilesystem you would type:

# mke2fs /dev/sda1

To format /dev/sda5 as a ext3 $ilesystem you would type:

mke2fs -j /dev/sda5

e2label
e2label is used to change the label of a ext2/ext3 $ilesystem.

e2label /dev/<disk device><partition> <label>

Example:
To label /dev/hda5 as home we would use:

e2label /dev/sda5 home

We can then check this by using the same command but dropping the label:

# e2label /dev/sda5
home

less
less allow you to view the contents of large $iles or the output of commands without them scrolling
off the screen. It allows you to move up and down the text using the cursor keys and to search for text.

less <$ilename>

Useful Commands:
q Quit
/<word> Search for the speci$ied word
n Go to Next occurrence of the searched for word
g<n> Go to line of text <n>
space Scroll forward one page (you can also use the Page Up and Page Down keys)

11 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

ls
ls lists the $iles within a directory. You can think of ls as being the same as the DOS/Windows
command dir.

ls /<path>/

Useful Options:
-l Long listing of $iles
-a Show all $iles
-h Human readable numbers, shows $iles in kb/mb instead of bytes
-n Show numeric user and group id
-r Reverse the sort order
-R List subdirectories recursively
-S Sort by size
-t Sort by time
-1 List one $ile or directory per line

Examples: Show all $iles in /home/england/ using the long listing:

# ls -la /home/england/
total 304
drwx------ 35 england england 4096 2008-06-09 09:24 .
drwxr-xr-x 7 root root 4096 2008-06-03 09:20 ..
-rw------- 1 england england 14093 2008-06-06 17:24 .bash_history
-rw-r--r-- 1 england england 18 2008-02-29 14:27 .bash_logout
-rw-r--r-- 1 england england 176 2008-02-29 14:27 .bash_profile
-rw-r--r-- 1 england england 229 2008-05-20 10:29 .bashrc

To show the same information, in a more human readable form, sorted for time we can use:

# ls -lahS /home/england
-rw------- 1 england england 14K 2008-06-06 17:24 .bash_history
-rw-r--r-- 1 england england 229 2008-05-20 10:29 .bashrc
-rw-r--r-- 1 england england 176 2008-02-29 14:27 .bash_profile
-rw-r--r-- 1 england england 18 2008-02-29 14:27 .bash_logout

scp
scp stands for secure copy and can be used to copy $iles to or from a remote server. It is a secure
transfer unlike FTP as it is using ssh encryption.

scp <$ilename> <hostname>:/<remote path>/

or

scp <hostname>:/<remote path>/<$ilename> /<local path>/

12 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

Useful Options:
-C Enable compression.

Example:
To copy my$iles.zip which are stored in /home/england/ to my current directory use:

# scp -C [email protected]:/home/england/myfiles.zip
/mnt/backup/myfiles.zip
[email protected]'s password:
myfiles.zip
100% 7912KB 36.6KB/s 03:36

vi
vi is a very powerful text editor which can easily have a whole book dedicated to it, so forgive me if
not everything is covered here! vi has two modes, a command mode and text entry mode.

vi /<path>/<$ilename>

Starting vi will The $irst thing you probably want to do when you $irst start vi is to $igure out how to
quit it ;o)

Exiting:
:q Quit (fails if anything has changed)
:q! Quit and throw away changes
Esc Exit mode
:w Write (save) the $ile, but don't exit
:wq Write (save) and quit

You can use the cursor and page up/down keys to move around a open document in Vi. If you pre$ix
any of these with a number the command will be repeated that many times. For example, type 4 and
the down cursor and the cursor moves down 4 lines. Press 2 and page up, and you will move up 2
pages.
To start to edit a $ile you need to change to "insert mode", this is done by typing i which should cause
the "-- INSERT --" to appear at the bottom of your screen. You can type away to your hearts content.
When you are $inished, hit Esc.

Basic Editing:
5yy Yank 5 lines, (p to paste them)
:3dd Deletes 3 lines
2G Jump to 2nd line
101G Jump to 101st line
G Jump to last line
yw yank word
p put (paste) the clipboard after cursor
dd delete (cut) a line

Insert Mode - Inserting/Appending text:

13 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

o Append a blank line below current line

r replace character under cursor with next character typed

R keep replacing character until [esc] is hit

i insert before cursor

a append after cursor

A append at end of line

O open line above cursor and enter append mode

Search/Replace:
/pattern Search for pattern
?pattern Search backward for pattern
n Repeat search in same direction
N Repeat search in opposite direction
:%s/old/new/g Replace all old with new throughout $ile
:%s/old/new/gc Replace all old with new throughout $ile with con$irmations

Learn VIm the funny way


Here's a website where you can learn VIm commands, playing a game : VIm Adventures (http://vim-
adventures.com/)

sed
sed is a Stream EDitor.

sed -e 's/oldstuff/newstuff/g' sedinputtext.txt

Example:
If we have the $ile sedinputtext.txt containing:

I love Microsoft.
Microsoft never crashes.
Linux is great.

And we run the following (the > sends the out put of the command to sedoutputtext.txt):

sed -e 's/Microsoft/Linux/g' sedinputtext.txt > sedoutputtext.txt

We get this output in sedoutputtext.txt.:

14 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

I love Linux.
Linux never crashes.
Linux is great.

External Link: Sed One Liners:

http://sed.sourceforge.net/sed1line.txt

awk
awk is used for pattern scanning and processing.

Example:
Lets say we want to get a list of logged on users and what time they logged in, and we aren't
interested in any other information. We can $ind out who is logged in by press w and enter:

# w
12:32:46 up 204 days, 10:04, 11 users, load average: 0.05, 0.12,
0.12
USER TTY FROM LOGIN@ IDLE JCPU PCPU
WHAT
grobert 10.67.13 10.67.13.42 5:59am 0.00s 0.00s 0.04s
/bin/zsh /home/grobert/.xse
mlow 10.67.14 10.67.14.118 8:02am 0.00s 0.00s 0.08s
/bin/zsh /home/mlow/.xsessi
mcneillk 10.67.18 10.67.18.168 11:22am 0.00s 0.00s 0.04s
/bin/zsh /home/mcneillk/.xs
glenwil 10.67.15 10.67.15.250 6:06am 0.00s 0.00s 0.05s
/bin/zsh /home/glenwil/.xse

To trim this down we can 'pipe' the information from w to awk using | and then just print $ields 1 and
4 (User and Login@):

# w| awk '{print $1,$4}'


USER LOGIN@
grobert 5:59am
mlow 8:02am
mcneillk 11:22am
glenwil 6:06am

Number of logged in Users

w|awk '{print $1}'|sort -u|grep -v ":"|grep -v USER|wc -l

15 of 16 9/18/2017, 1:58 PM
Basic Linux Commands - Amazon Wiki https://w.amazon.com/index.php/Basic_Linux_Commands#mv

External Link:
Awk is a powerful tool and deserves further reading:

http://www.student.northpark.edu/pemente/awk/awk1line.txt

External Reference
There is also a repository at Github (https://github.com/jlevy/the-art-of-command-line) with most
commonly used commands that are operating system agnostic.

Retrieved from https://w.amazon.com/index.php/Basic_Linux_Commands

was last modi$ied on 11 June 2017, at 16:54.

This page is already flagged. Leave


a comment on the Discuss page!

16 of 16 9/18/2017, 1:58 PM

You might also like