Comandi shell per Linux
Aggiornare Ubuntusudo apt-get update (aggiorna l'indice)
sudo apt-get upgrade (aggiorna i pacchetti)sudo apt-get dist-upgrade (aggiorna l'intera distribuzione)
sudo apt-get clean (rimuove i files dei pacchetti scaricati)
sudo apt-get install nomepacchetto (installa nomepacchetto)
sudo apt-get remove nomepacchetto (rimuove nomepacchetto)
Installare SSH Serverapt-get install openssh-server
Abilitare SSH solo a certi utenti
Editare il file /etc/ssh/sshd_config aggiungendo i nomi degli utenti che possono entrare tramite ssh
AllowUsers utente1 utente2
Print the fingersprints of the host keys
ssh-keygen -l -f HOST_KEY_FILE
Copiare file da locale a remoto e viceversa tramite SSHscp localfile name@host:/remotefolder/scp name@host:/remotefolder/remotefile /localfolder/
RSA Key-Based SSH Logins
Generating RSA Keys using passphrase:ssh-keygen -t rsa
Locating the Keys on Remote Computers:ssh-copy-id -i ~/.ssh/id_rsa.pub username@host
Testing the Login:ssh username@host
RSA key-based logins as the only acceptable form of authentication:
edit /etc/ssh/sshd_configPasswordAuthentication noPermitRootLogin without-password #root may logging in with a public key only
Eseguire comando da remoto con SSHssh -t user@host sudo comando
Configurare al volo la scheda di retesudo ifconfig eth0 xxx.xxx.xxx.xxx netmask nnn.nnn.nnn.nnn upsudo route add default gw yyy.yyy.yyy.yyy eth0
Spegnere il sistemasudo shutdown now -h
Creare un Link Simbolicoln -s target nomelink
Cercare un filefind /directory/dove/cercare/ -name termine_da_cercarefind /directory/dove/cercare/ -ctime età_in_giornifind /directory/dove/cercare/ -size dimensione_in_K
Cercare una stringa in un filegrep stringa *.htmlgrep -w "stringa" *.html (w=word)
grep -r "string" * (r=recursive)
Cercare i files più grandi
find . -type f -printf "%k %p\n" | sort -rn | head
Contare il numero di files contenuti in una cartella e sottocartelle
find Cartella -type f | wc -l
Contare il numero di un certo tipo di files (es: wav)
find Cartella -name *.wav | wc -l
Spazio su discodf
Accedere a shell come rootsudo -i
Creare utente tramite script#!/bin/bash
username=$1
password=$2
sudo useradd -m $username -p `mkpasswd $password`
Cancellare utentesudo userdel -rf nomeutente
Cambiare la passwordpasswd
Cambiare la password di rootsudo passwd root
Aggiungere un utente ad un grupposudo gpasswd -a nomeutente nomegruppo
Versione di Ubuntulsb_release -a
Versione di kernelsudo uname -r
Unrarunrar x nomefile
Upload di files su Server FTP
ftp -pi nomeserver
(p: passivo, i:no interattivo)
digitare user e password
localizzarsi sulla cartella localelcd /mia/cartella/locale
se files testo digitareascii
per altri files digitarebinary
trasferire file (ad esempio mp3)mput *.mp3
uscirequit
Visualizzare PDFpdftotext -layout nomefile.pdf - | less
Cercare in un PDF (A righe prima e B righe dopo)pdftotext -layout nomefile.pdf - | grep -i -A 1 -B 2 "testo_da_cercare" | less
Aprire il cassetto del CD playersudo eject /media/cdrom0
Chiudere il cassetto del CD playersudo eject -t /media/cdrom0




