Archive for the ‘ All OS and Versions ’ Category

Monitoring your system basics
 
To check the disk usage on your system
~# df -h

To check the memory allocation and usage
~# free -m

To visualize your CPU information
~# cat /proc/cpuinfo

To check your network configuration
~# ifconfig

To visualize the running processes, CPU Load and Memory
~# ps aux

To see lifetime running processes
~# top
( type q to leave the program )

 

Setting File and Folder Ownership
 
Every file or folder belongs to an owner and a group
To change ownership use the syntax:
~# chown username:usergroup filename
~# chown username:usergroup foldername
To change ownership recursively, meanwhile all files inside a folder:
~# chown -R username:usergroup foldername
To check and visualize your changes type:
~# ls -hal

 

Setting File and Folder Permissions
 
Permission are represented by a 3 digit numerical code
First Digit: Owner
Second Digit: Group
Third Digit: Everybody

Permission 0 = no access
Permission 4 = read
Permission 6 = read / write
Permission 5 = read / execute
Permission 7 = read / write / execute

To set permissions use syntax
~# chmod 644 filename
Setting filename to read/write (owner) and read (group and world)
To set permissions recursively for all files inside a folder use
~# chmod -r 755 foldername
Setting foldername and all files inside to raed/write/execute (owner) and read/execute ( group and world )

You can restrict your settings and give permissions only for specified files
~# chmod 644 *.php
Setting all php files inside this folder to read/write – read – read

 

Copy / Paste files and folders.
– copy a file
~# cp filename1 filename2
A copy from filename1 is created in the same directory
~# cp /home/myweb/filename1 /home/hisweb/filename2
Creates a copy from filename1 into another directory and name filename2
To copy a folder use the -r ( recursive option )
~# cp -r folder1 folder2
~# cp -r /home/myweb/folder1 /home/hisweb/folder2

To copy and preserve the user and group rights use the -p flag
~# cp -rp filename 1 filename2
To show all options type:
~# cp –help

 

To move a file or to rename a file use:
~# mv filename1 filename2
For folders addd the -r ( recursive ) flag
~# mv -r folder1 folder2

 

To create a dump file use the following syntax:

/var/lib/mysql # mysqldump -u root -p mysqldatabase > backup.sql

You will be prompted for the password and the backup file will be created.

————————————————————————-

To restore a backup dump file use the following syntax:

/var/lib/mysql # mysql -u root -p mysqldatabase < backup.sql

You will be promted for the password and the backup will be restored.

 

To change date and time on your shell manually you need type the following code:

~# date --set 2008-11-19
~# date --set 15:25:0

Make sure to respect the syntax.