0% found this document useful (0 votes)
14 views6 pages

Essential Linux Commands Guide

This document describes numerous Linux commands for navigating directories, listing and copying files, deleting and creating directories, moving or renaming files, searching and modifying contents, archiving, system administration commands, and process management.
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)
14 views6 pages

Essential Linux Commands Guide

This document describes numerous Linux commands for navigating directories, listing and copying files, deleting and creating directories, moving or renaming files, searching and modifying contents, archiving, system administration commands, and process management.
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

Linux commands

By ¥@$$!N€
Navigate through directories (Change Directory)

. Current directory.
.. Parent directory.
/ Racine
cd (space) .. Climbing up a level
cd- Return to the previous directory

List the files in a directory: (List Sorted)


ls -l Allows listing the attributes of files
ls -d Display only the directories
ls -a List all files in the directory, including hidden files.
ls -m Display the files separated by a comma.
ls -t Display the files by date.
Displays
list files with their last access time files by date of last access and indicates the date.
ls -F Display files by type
ls -S Display the files sorted by decreasing size.
ls -X Display files by file type
ls -r Display the files in reverse alphabetical order
ls -alR/ List all files in a system
ls -alR | [Link] Display all files containing doc

Copy a file or directory: (copy)

cp Ask if it can overwrite the file name: respond with Yes (y) or No (n)

Warns of the existence of a file with the same name and asks whether it can or cannot
cp -i
replace.

cp -l Allows to make a "hard" link between the source file and its copy

cp -s Allows for a "symbolic" link between the source file and its copy

[Link] 1 By$$€
cp -p Allows preserving all information regarding the file when copying.

Allows for recursively copying an entire directory and its subdirectories.


cp -r
directories
Allows, like the -i option, to ensure that the copy does not overwrite an existing file: the
cp -b the overwritten file is saved, only the file name is modified and cp adds a tilde
(~) at the end of the file name.

Remove files and directories:


remove directory)

remove directory Allows you to delete a directory whether it is empty or not

rm -r Allows you to delete a directory and its subdirectories

rm -f Allows the deletion of write-protected files and directories without confirmation

rmdir Delete a directory

rmdir -p rep1/ rep2 /rep Delete the directory and its associated subdirectories

Create directories:

mkdir Create a directory

mkdir -p rep1/rep2/rep3 Create a directory and its associated subdirectories


Move or rename a file:

mv -b Make a backup of the files before moving them

mv -i Request for each file and each directory whether it can be moved or not.
Ask 'mv' not to delete the file if the modification date is there.
mv -u
same as or newer than its replacement.

Research, analysis, modification of content


find / Search from the root of the current file
find -name Specify a filename
find -print Display the result on the screen
diff Display differences between files
cmp Binary comparison
cat and more View a file

[Link] 2 By$@$$ing
sort Sorting of lines
Location of the file system mount (partitions) and the remaining space on
df
each of them
Allows applying commands on a file and displaying the result without
But
modification of the file.
you Give the disk space used by the current directory.

wc Counting words, lines, or characters

file Give the file type


Finding a regular expression in a file: (grep) gives the number of times
grep -c
where the regular expression was found in the file:
grep -n To search for regular expressions starting with a dash
find, locate and which Find a file

Other Commands

pwd Where am I?
man Search for information about an order.
which Allows to know the path of an executable
mdir Display the list of files on an MS-Dos floppy disk.
mkmode Create a unique temporary file name
emacs, joe Edit a file
UNIX allows creating multiple links to the same file with the
ln
order
who List the users connected to the station
free Used memory
clear Clear the screen
touch Updates the access dates of the files
logout Allows to close your user account
logname Allows you to know under which name you are logged in

tar Data archiving: the order


q leave

Start, Restart & Stop

startx start Xwindows under linux

reboot restart the machine

[Link] 3 By$@$$ing
shutdown -r stop and restart (reboot).
shutdown -h shut down Linux properly.
exit Disconnecting the current user

Archiving
gzip The compression and decompression of files in gz format

gzip -gv [Link] Compress the current directory and create the file [Link]

gzip -d [Link] Decompress [Link]

tar -zcvf /usr/pluton /home Backup the home directory to Pluto

tar -zxcf /usr/pluton /home Restore Pluton in the home directory

Linux system administration command


table containing commands that need to be executed periodically. It's the
cron program that runs the command. The periods can be
crontab
hours ([Link]), days ([Link]), weeks ([Link]) or months
([Link]).
cron Software tool available on Unix that allows periodic launching of
processes indicated in the crontab.
at Command to launch another command or a process with a delay.

chmod Place the usage rights of the files

change owner Designate the user and group owner of the files

adduser Add a user

password Specify or change a password

chfn Describe a user

userdel Delete a user

mount Use your CD-ROM, your floppy disk drive

shutdown -h Stop the system

lilo -u Uninstall LILO


mkbootdisk (device /dev/fd0 [Link]) Create a Boot disk

System Messages

[Link] 4 By$@$$in€
cat /proc/interrupts Display the IRQs used
cat /proc/ioports Display the used I/O ports
cat /proc/dma Display the use of DMA channels
cat /proc/pci Show the use of PCI ports
Process management:

top allows tracking the resources that the process uses

ps allows one to know the active processes at a given time


allows displaying processes in a tree structure, thereby seeing their
pstree
interdependencies
Allows you to kill a running process: syntax kill [option] PID. To kill the
process, I can first do anps -ax to know the PID number and
kill
then if for example the PID is 3600, I can kill the connection by doing
[root@localhost/root]# kill 3600
Organization of directories(tree structure of a classic UNIX system)
/
Root directory, all other directories depend on it.
/bin
Contains the essential binaries for managing Linux.
/dev
Contains a multitude of so-called special files. One of them corresponds to my modem. I have to indicate
this file in the configuration of my communication tools. Similarly, /dev/hda1 corresponds to the
first partition of my IDE hard drive, if my hard drive is a SCSI, its name will be /dev/sda1. A
last example: /dev/fd0 corresponds to my floppy disk drive.
/etc
Contains all the configuration files of Linux. For example, the file /etc/passwd is found there.
who defines the users' passwords.
/sbin
Contains the system binaries. For example, there is the shutdown command which allows you to stop.
the computer.
/home
Directory that contains the directories of the system's users. The users' directory is
automatically created with the creation of an account. All my personal files are in
/home/(maltesse).
/lost+found
Directory of lost files. These famous files that, due to disk error, end up without
access path. The fsck binary, which is regularly run at the startup of Linux, is responsible for them
detect and store them in the /lost+found directory
/tmp
Directory accessible by all system users, it helps avoid cluttering one's directory.
personnel by files that we wish to destroy or modify in any case.
/var/spool
Directory of files that serve as a queue. For example, printer queues
found under this directory. The data to be printed, sent, ... is stored in these queues.
until they are processed.
/usr

[Link] 5 By $ince
Contains everything related to useful binaries for all users and some commands
administration. However, there are other things: /usr/bin therefore contains the available binaries
for users and scripts.
/usr/X11R6
Contains everything related to Xfree86 (the libraries, the binaries, the documentation).
/usr/include
contains all the necessary 'headers' for programming in different languages.
/usr/lib
Contains all the libraries necessary for the operation of the software. (for example, the
C or C++ or tcl/tk library.
/usr/local
You can put whatever you want in it, but especially local use files.

[Link] 6 By the way

You might also like