Linux commands Flashcards
list
ls
remove
rm
delete empty directories/folders
rmdir
show place
pwd
create folder/directory
mkdir
create a directory under another directory
the one to create AA under director BB
mkdir AA/BB
go to XX
cd XX
go to home
cd ~
go back one step before
cd..
home
~
parent folder
..
current folder or place
.
list of history of creation and owners and rights of file X
ls -l X
root
/
edit if a XX text file exists or create it
nano XX.txt
open a temp space for a text file to name it and save it after done writing
nano
read text file XX
cat XX.text
get immediately into file ZZ that is in XX that is in home
cd ~/XX/ZZ
clear steps
clear
remove full directory XX that is not empty step by step
rm -rfi XX
move a X file or directory from A directory to B directory, while B is A’s parent directory
mv X ..
rename a file X to Z
if Z exists it’s a replacement
mv X Z
command moves all files and directories under book to the directory named manual, if manual exists. Otherwise, the directory book is renamed manual.
mv book manual
command moves intro to manual/chap1. The name intro is removed from the current directory, and the same file appears as chap1 in the directory manual.
mv intro manual/chap1
command moves file chap3 to manual/chap3
mv chap3 manual
move several files into one another directory,
command moves the chap4 file to the /home/manual/chap4 file directory and the jim/chap5 file to the /home/manual/chap5 file.
mv chap4 jim/chap5 /home/manual
use the mv command with pattern-matching characters
This command moves all files in the manual directory into the current directory . (period), retaining the names they had in manual. This move also empties manual.
mv manual/* .
list command or description
man
delete everything that starts with chap
rm chap*
delete everything that ends with .jpg
rm *.jpg
name the three types of right owners
user
group
other
what is User
how to change it
the owner/creator of the file
sudo chown new-owner filename
what is Group
how to change it
group: new group
filename: file to change his group
contains multiple users/owners
sudo chgrp group filename
show AAA.txt text file with line numbers
cat -n AAA.txt
show AA.txt file while specififying numbers of lines
number of lines 5 for example going from the head
cat -n AA.txt | head -5
show multiple text files
cat file1.txt; file2.txt;
create a file with cat
cat >file1.txt
show more or less when content is too much
cat song.txt | more
cat song.txt | less
show symbol $ at the end of every line or gap between paragraphs or end of the file
example
hello everyone, how do you do?$ $ Hey, am fine.$ How's your training going on?$ $
cat -e test.txt
Redirecting/cut Multiple Files Contain in a Single File
cat test1 test2 test3 > test
redirect one file to another one
cat test > test1
existing contents of the test1 will be overwritten by the contents of the test file.
copier contenu de test.txt et le coller à la fin de test1.txt
cat test.txt»_space; test1.txt
supprimer avec confirmation le fichier AA.txt
resultat: remove regular file?y
rm -i AA.txt
commande pour changer en administrateur
root
comment ajouter et supprimer un utilisateur
deluser X
adduser X
comment ouvrir un utilisateur X
su X
et ecrire le mdp
comment modifier la date de modification d’un fichier X
et si X n’existe pas, elle creer un fichier vide nommé X
touch X
comment chercher les dossier .jpg
locate .jpg
comment fair eune mise a jour dans linux et telecharger une commande comme locate
sudo apt-get update
sudo apt install mlocate
comment trouver tous les fichier qui surpassent par exemple 10megabytes
find -size +10M
comment trouver les fichiers inferieur à 1mega dans la directoire DD
find DD -type f -size -1
chercher toutes les directoires dans home
find ~ -type d
quels sont les droits des fichiers
r: lecture/copier
w: ecriture
x: execution
chercher fichiers jpg dans directoire DD
find DD/*.jpg -type -f
comment changer les droits
3 méthodes sudo chmod u-w+x,g-w+x,o+w chmod 556 (methode de binaire et d'addition)
calculer les droits par défaut
pour 002
umask 002
valeur par défaut 666
determiner la valeur binaire de 002
000000010 et la convertir par la non logique 111111101
666 est egale à 110110110
multiplier bit par bit 110110110 et 111111101
et convertir resultat 110110100
rw-rw-r–
afficher les lignes ou le mot “linux” apparait dans os.txt
grep -i linux os.txt
compter exactemement l’occurence en etant sensible au majuscule
grep -c linux os.tx
compter exactemement l’occurence sans être sensible au majuscules
grep -c -i linux os.txt
afficher les lignes dans tous les fichiers qui contienne linux
grep -i linux *
afficher ou existe le mot linux
grep -l linux *
afficher les fichiers qui contiennent linux
grep -i -l linux *
afficher les lignes et leurs nombres qui contiennent linux
grep -i -n linux *