Commands SSH Linux / Debian

Speak
Clear All
List of Linux commands / Debian (valid for most Linux distributions).

Some of these commands are not included in the standard Linux system installation, if you want to use a command that is not available by default, you install it or install package that contains.

See: Installation and easy uninstallation of packages
File handling

List of files

ls …………………………….. List of files in a directory.
ls -l ………………………. Also the list of the properties and attributes.
ls -lh ……………………… List the files with size in MB and GB.
ls -la ……………………… List of files including hidden system files.
ls – la | more ……………….. List of files in a directory in a paged way.

Access rights to the files or directories

See: Access rights on files or directories

Displays the contents of a file

Cat n file… Displays the contents of a file (n number all lines).
PR t file… Formatting text for printing files (t do not display the header and footer).

cat file | less -.
cat file | more-|
| ––– Displays the contents of a paged file.
more file |
less file-‘

zcat file -.
zmore file-| ––– displays the contents of a compressed file (.gz)
zless file-‘

Display

echo text… Displays the text that follows.
grep ‘text’ file… Displays the rows of the file containing the text.

Stat file… Indicates the status of a file.
Stat f file… Indicates the State of the file system.

file file… It shows the nature of a file.

tail file… Displays the last lines of a file, default 10.
tail n 12 file… Displays the last 12 lines of the file.

head – Nº file… Displays the first (No.) lines of a file.

WC file… Indicates the number of words, lines, and characters in a file.
WC-c-file… Displays the size of a file in bytes.

Touch [-am] [-t] file… Change the access and modification dates.

Search for files

find/usr – name lilo – print… Seeks all files with a name lilo in/usr.
find/home/toto – name *.jpg – print… Seeks all .jpg images.
———- ———- —–
| | |
V V ‘ ––– displays the full path of the file.
path model research

Copying files

CP – dpR filename1/path/filename2… Make a copy of/path/File2 File1, rename.
-R ………………………… Recursively copies a directory, with the exception of special files.
-p ………………………… Preserve a copy of the permissions, owner, group, and dates.
-d ………………………… Preserves symbolic links.
-a ………………………… As – dpR.

Move or rename files or directories

MV/path/filename1/path/filename2. Move or rename files or directories.

Delete files

RM files… Removes the files.
RM-r directory… Removes the files in a directory recursively.
rm *.jpg ……………………. Removes all .jpg current directory files.

Links

LN file/path/link… Create a link.
ln-s/path/link directory… Create a symbolic link.

Compare files

diff [options] file1 file2… Compare files.
diff w file1 file2… Discard empty lines per report.
diff q file1 file2… Reported only if the files differ.
diff y file1 file2… Displays the output of two columns.

join [options] file1 file2… Displays the rows are equal.

Split a file

split b 1445640 mozart.ogg mozart -… Split a file.
———- ——-
| V
| name chosen for the parties
V
size in bytes of each party

Cat mozart.* > mozart.ogg… Assemble the different parts of a file split with split.

Nano – read, create, edit a text file

Nano file… Read, create, edit a text file.
Ctrl + g …………………… Invoke the Help menu.
Ctrl + x …………………… Exit nano.
Ctrl + o …………………… Write the fic
Enter a directory

CD directory… Change directory.
CD… ………………………. Return to the previous directory.
CD./.mozilla… Enter the directory of Mozilla. (indicating the relative path).
CD /home/toto/.mozilla… Enter the directory of Mozilla. (specifying the full path).

Create and delete

mkdir directory… Create a directory.
rmdir directory… Removes an (empty) directory.
RM-r directory… Removes a directory.

Size of a directory

the h directory… Space on disk.

Administration

Scheduled tasks

See: Scheduled tasks

Start, stop, and restart services

/etc/init.d/service stop… Stop a service/daemon.
/etc/init.d/service start… Start a service/daemon.
/etc/init.d/sservice restart… Restart a service/daemon.

User management

su ………………………… Enter the session as root or another user.
Su user… As root, enter as another user.
passwd …………………….. Change your password.
who -a -H ………………….. Displays information on the part of connected users.
users ……………………… Displays information on the part of the users connected to the system.
id ………………………… Displays information for the current user.
groups …………………….. Displays the groups to which they belong to a user.

adduser user… Create a new user.
adduser user group… Add an existing user to an existing group.
adduser – no-create-home user… Create a user without a directory (home).
addgroup group… Create a new group.
deluser user… Remove a user.
deluser user group… Removes a user from a group.
deluser – remove-home user… Removes a user and their (home) directory.
delgroup group… Deletes a group.
usermod-l new_utilisateur… Change the name of the user.
usermod-d new_home m user… Change the directory (home) of a user.
groupmod n new_nom grupo… Change the name of a group.

System

free -m -s 3 ………………………. Displays the memory usage every 3 seconds.

df -h …………………………….. Size, space used and the space available on each disk partition.

netstat – napt… Know which ports opened our system.

Logs

tail/var/log/syslog… Message logging safety.
tail/var/log/debug… Information for debugging programs.
tail/var/log/messages… System of information messages.
tail /var/log/user.log… Information about the user.
tail /var/log/auth.log… Access to the system (including the failed attempts).
last ……………………………… List of connected users / disconnected.
lastb …………………………….. Displays login attempts failed.

Process

htop need installation of package htop.

ps aux …………………………… Displays information about the current process.
top ……………………………… Displays information about the current process.
htop …………………………….. Is a system monitor that allows you to filter processes
by memory consumption or processor.
pstree …………………………… Displays the process tree.
pidof command… Find the ID of a program that is running.
killall process… Stop a process.
strace command… Indicates a process-generated system calls.
fuser v file… Displays the processes that use a file.
lsof | less ………………………. List of files opened by the process.
lsof-c-command… List of files opened by a process.
lsof + D/home/paco… Lists processes that use my directory.
lsof-i: 627… Shows process is found behind the port 627.

nohup command &… Initiation of a process in the background and continuous.
commande & ……………………….. Run a command in the background.
jobs ……………………………. Lists the second plan process with a number of task.
fg nº ……………………………. He moved to