Debian_FAQ
How to find out the version of an installed program in Debian
You need to run the command
dpkg -p program_name
Check kernel version Debian
You need to run the command
uname -r
How to find out the Debian version
You need to run one of the commands
hostnamectl (will also output the Machine ID and Boot ID)
cat /etc/issue (the answer will tell you whether you are on sid or not)
lsb_release -a (the answer will tell you whether you are on sid or not)
cat /etc/debian_version (the answer will tell you whether you are on sid or not)
cat /proc/version (the answer contains the kernel version and gcc)
How to restart X-server
You can restart X-server (after first switching to the console with Ctrl + Atl + F1) with the command
/etc/init.d/gdm restart
or
/etc/init.d/gdm3 restart
or
/etc/init.d/kdm restart
How to stop the X server
You can stop/start X-server (after first switching to the console with Ctrl + Atl + F1) with the command
/etc/init.d/gdm stop
or
/etc/init.d/gdm3 stop
or
/etc/init.d/kdm stop
If you do not know which X server you have, you can try:
/etc/init.d/gdm stop || /etc/init.d/gdm3 stop || /etc/init.d/kdm stop || /etc/init.d/xdm stop || /etc/init.d/lightdm stop
If that did not help either, try the options from here
or from here.
How to start the X server
/etc/init.d/gdm start
or
/etc/init.d/gdm3 start
or
/etc/init.d/kdm start
It works if you have the X-server gdm, gdm3 or kdm; if you have something else, just replace it.
Where the bootloader Grub lives in Debian
Either
/etc/default/grub
Or the scripts from
/etc/grub.d
How to enter a folder in Debian
To enter a folder you need to run the command
cd folder_name
Live usb user password
Try
live
it worked on 26.12.2014 for this image.
Send email in linux
To send email you need to enter the following on the command line
mail -s "Email subject" user@domain.ru
If you need to send the contents of a text file
mail -s "Email subject" user@domain.ru < /home/user/filename.txt
How to delete a file in linux
rm file_name
How to switch from the console to X
Alt + F7
How to switch from X to the console
Ctrl + Alt + F1
How to view the list of active connections in Linux
netstat
Links:
http://man7.org/linux/man-pages/man8/netstat.8.html
https://en.wikipedia.org/wiki/Netstat
ifconfig command not found debian
If ifconfig produces the error ifconfig command not found debian, you can either use the command
ip addresses
Or install ifconfig
How to exit a program in debian
To stop a running program press
CTRL + C
Change Gateway
Deleting the old gateway
route delete default
Adding a new gateway
route add default gw IP_Address
If there are many old gateways, then you need to specify which exact IP should be deleted from which interface
route delete default gw 10.0.0.1 eth0
For creation you can also specify concrete data
route add default gw 192.168.0.1 eth0
How to copy a folder in linux
cp -r source destination
How to find out how much free space there is in linux
df
Or install gparted
apt-get install gparted
gparted
How to send data from linux
Suppose there is an old server somewhere that simply listens on some port and
you need to send data to it.
You have sorted out the protocol, or it is not required. You have written the data to the file message.msg
Let's denote the server address as url and the port as port
First you need to install netcat
netcat url port < message.msg
or
cat message.msg| nc url port
Example
netcat devserver 8085 < message.msg
How to count the number of lines in a linux file
To count how many lines there are in a file, use
wc -l project-name-2019-09-25.log
282608 project-name-2019-09-25.log
How to clear a file in linux
To delete the contents of a file, use
: > file_name
-bash: man: command not found
To install the man reference
sudo apt update
sudo apt-get install man-db
bash: adduser: command not found
Usually, to create and edit users you need to have quite a lot of rights.
Often this is done as root.
Starting with Debian 10 a surprise from the developers awaits us. If you became root
the old way by running su without arguments, your system variable
PATH
most likely does not contain many of the required directories.
All because the su command now comes from another package - util-linux instead of shadow
and does not update PATH by default.
What to do
Try
su - root
Details here
How to make sudo
For a user to be able to run the sudo command successfully, they must be added
to the sudo group.
You can check whether the user andrei is in sudo with the command
groups
If the result is approximately like this
andrei cdrom floppy audio dip video plugdev netdev bluetooth lpadmin scanner
That is, sudo is not in the list. You need to add it with the command
adduser andrei sudo
If everything went well, you can check that sudo is now in the list of groups
groups
andrei cdrom floppy sudo audio dip video plugdev netdev bluetooth lpadmin scanner
If something went wrong - read the notes.
Note 1
To add a user to the sudo group, you will most likely need to log in as
root.
Starting with version 10 this is not so trivial.
Note 2
If in one terminal you see that the user is already in the sudo group but in another terminal they cannot run sudo - execute the command
exit
And log in again.
Note 3
The description of who can use sudo and how is in the
file /etc/sudoers
You do not need to edit it directly, you can go to
/etc/sudoers.d
or call the utility from under root
visudo
And change something there at your own risk.
How to add a Russian keyboard language
We open the file /etc/default/keyboard with the command
sudo vi /etc/default/keyboard
We find the required lines
And add ,ru to XKBLAYOUT="us" and grp:ctrl_shift_toggle to XKBOPTIONS=""
The result will be a piece like this
XKBLAYOUT="us,ru" XKBVARIANT="" XKBOPTIONS="grp:ctrl_shift_toggle"
Note 1
If editing files in the editor causes you difficulties
vi
Read the article
«An example of using VI to change the language in Linux»
How to view the list of open ports
ss -ltupn
What file types there are in Linux
Seven file types are available: regular, directories, character, block, sockets, named pipes, symbolic links
- : regular file
d : directory
c : character device file
b : block device file
s : local socket file
p : named pipe
l : symbolic link
How to send a file over ssh in Linux
Suppose you need to send the file
big_file
to a remote host with the IP 192.168.0.2
and put it in the home directory.
On the remote host you have the user
andrei and you know their password
scp big_file andrei@192.168.0.2:/home/andrei
To send not a single file but a directory with all nested files use the -r option
scp -r directory andrei@192.168.0.2:/home/andrei
Article author: Andrei Olegovich