Linux tips

Some tips for the Linux shell command.

Nav

pwdabsolute path of the actual repertory
lslist of files and repertories
cdgo in the repertory
mkdir repertoryNamecreate a new repertory
cp -r -v originalRepertory new Repertoryrecursive copy of a repertory
rm fileToBeDeleteddelete file
rm -rf repertoryToBeDeleteddelete recursively a repertory
mv originalFile newFilemove file
sudobefore command for use the administrator

Weight

du -sh RepertoryNamedisplay the weight of a repertory
df -hfree space of the disks

Process

pslist of the process running
ps -elist of all the process of the system
ps -e -o"%p %P %U %c"display PID, PPID (parent PID), user, program

Program

g++ -o programName sourceName.cppcompile C++
g++ sourceName.cpp -lpthread -o programNamecompile C++ with library
./programNameexecute C++
(ctrl)+cclose the program
./programName &run an unclosable program

USB

ls -l /dev/disk/by-id/*usb*identify the USB input
sudo mount -t ext3 /dev/sdb /media/INTRASAVEmount an USB key
umount /media/RepertoryNameumount the USB
sudo fdisk -lfind an USB key
lsusb

SSH

scp originalFile userName@serverIP:/pathpush a file in SSH
scp -r repertoryName userName@serverIP:/pathpush a repertory in SSH
scp -r userName@serverIP:/path repertoryNamepull a repertory in SSH

Update

apt-get updateupdate depots database
apt-get upgradeupdate the system
apt-cache search softwaresearch exact name of a software
apt-get install softwaredownload and install a software

MySQL

mysqldump -u user -pPassword --all-databases > ~/fileName.sqlsave all databases, User can is root and password empty

User

adduser userNamecreate an user
mkdir /var/www/dirName

usermod -d /var/www/dirName userName

chown userName /var/www/dirName
change the main directory of the user
sudo mount --bind /var/www/dirName /home/userNamechange the default ftp landing directory