8.2 KiB
title : Linux 101 author: zvevqx published: 2025-11-22 cat: linux desc: ws
...
learn more about ssh -> https://www.ssh.com/ssh/
- linux :
start terminal ctrl + alt + t
ssh -p portnumber pi@ipaddress
ssh user @ distant_server.address : connection_port (default to 22 )
ssh pi@192.168.1.24
⚠️ linux user : to copy inside the
terminal: ctrl + shift + c to paste inside theterminal: ctrl + shift + v
-
Osx :
start terminal ( 🍎 + space and search for
terminal)
ssh -p 55 pi@er401.duckdns.org
- Windows :
- install
putty- got to putty download page
puttywill givewindowssshability ...
- got to putty download page
- connect to:
- server:
ipadresse - port
22 - user
pi
- server:
create your new home
first
- create a User
sudo useradd <username>
- add user to groups and privilege
- add user to
adminlist
sudo usermod -a -G sudo yourUserName
- change shell to
zsh( optional )
chsh -s /bin/zsh
- exit user
pi
exit
- reconnect with your
usernameandpassword
ssh YOUR_USER_NAME@ADRESSEIP
-
welcome to your new
home- your home folder is in
/home/yourUserName- hint : you can check where you are with the command
pwd(Print Working Directory)
- hint : you can check where you are with the command
- learm about linus folder structure -> learn more
- your home folder is in
DO SOME STUFF
general cli commands
navigate
.the current directory ( folder)..the parent directoryman: view the manual of a command ( ex :man ls)pwd: Use the pwd command to find out the path of the current working directory (folder) you’re incd: change directory to go inside a new directoryls: list the current directory contentcp: to copy documents / foldersmv: to move documents / foldermkdir: make directory create a foldertouch: create an empty filerm: remove folder and files ⚠️ no return possible / read and think twice before smashing enterfind: to find / search for files
system stuffs
sudo: super user do get super privileges to do system stuff ⚠️sudocan do ANYTHING , even destroy systemdu: disk usage ... to see .. disk usage ( use it with-hargument for human readable output )topandhtop: to monitor system ( application / ram / cpu usage)killall: kill a process by name e:killall firefoxwill quit and kill all firefix processuname: view system information ( kernel / linux version ....)sudo reboot: restart computer ( must besudoto execute )sudo halt||sudo shutdown now: shutdown computer ( must besudo)
general help
- ctrl + r : search in history for already used commands
- ctrl + c : kill running command
getting started with python
==underconstruction==
just some code to try
import time
import math
x = 0
try :
while True:
x = x+1
time.sleep(0.5)
print(" la vlaeur de x est de = {}".format(x))
if x>100:
x=0
except KeyboardInterrupt:
print('Hello user you have pressed ctrl-c button.')
create a simple chat with python
https://python.plainenglish.io/create-a-basic-lan-chat-room-with-python-f334776bf70c
fixed code
===client===
import socket
import threading
my_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
PORT = 8000
ADDRESS = "localhost" # Same as "127.0.1.1"
my_socket.connect((ADDRESS, PORT))
nickname = input("Choose your nickname : ").strip()
while not nickname:
nickname = input("Your nickname should not be empty : ").strip()
def thread_sending():
while True:
message_to_send = input("your message :")
if message_to_send:
message_with_nickname = nickname + " : " + message_to_send
my_socket.send(message_with_nickname.encode())
def thread_receiving():
while True:
message = my_socket.recv(1024).decode()
print(message)
thread_send = threading.Thread(target=thread_sending)
thread_receive = threading.Thread(target=thread_receiving)
thread_send.start()
thread_receive.start()
===server===
import socket
import threading
my_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
PORT = 8000
ADDRESS = "0.0.0.0"
broadcast_list = []
my_socket.bind((ADDRESS, PORT))
def thread_accept():
while True:
my_socket.listen()
client, client_address = my_socket.accept()
broadcast_list.append(client)
start_listenning_thread(client)
def start_listenning_thread(client):
client_thread = threading.Thread(
target = listen_thread,
args = (client,) #the list of argument for the function
)
client_thread.start()
def listen_thread(client):
while True:
message = client.recv(1024).decode()
if message:
print(f"Received message : {message}")
broadcast(message)
else:
print(f"client has been disconnected : {client}")
return
def broadcast(message):
for client in broadcast_list:
try:
client.send(message.encode())
except:
broadcast_list.remove(client)
print(f"Client removed : {client}")
thread_accept()
create folder in apache server
wft is apache :
apache is a http web server wiki page
there other solution like [https://www.lighttpd.net/]{https://www.lighttpd.net/} or the popular https://nginx.org/en/
apache is well documented and often the one you'll find on a web server service
- create folder first with your username
sudo mkdir -p /var/www/html/$USER
- change ownership to your user
sudo chown -R $USER:$USER /var/www/html/$USER
- make sure permissions on
wwware ok
sudo chmod -R 755 /var/www
- create your first webpage to serve
touch /var/www/html/$USER/index.html
- put something in it
nano /var/www/html/$USER/index.html
or
vim /var/www/html/$USER/index.html
- content example
<html>
<head>
<meta charset="UTF-8">
<title>Welcome to my page</title>
<style>
h1{
font-size : 42px;
}
</style>
</head>
<body>
<h1> 📡 Success!! 📡 </h1>
</body>
</html>
mjpeg-streamer ( video server )
https://github.com/jacksonliam/mjpg-streamer
⚠️ don't follow the instructions during this class ( installation already done )
- after install
-
add your user to
videogroupusermod -a -G video $USERthis will give your user to access camera equipement
-
logout and back in
-
go have a look
- start server
cd ~/mjpg-streamer/mjpg-streamer-experimental && ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so" -
go check
#in a local network http://IP_FOR_THE_RASPBERRY_PI:8080/?action=stream #in that case with dyndns service ( duckdns ) and port redirection ( 666 -> 8080) http://er401.duckdns.org:666/?action=stream
-
