affiliate_link

Linux Basics




Linux Commands


 ls               -  show files in current path
 cd              - change directory
 cat             - display file contents
 vi / vim       - Editor
 pwd           - show current path
 man            - Help
 su              - switch user 
 passwd      - change password
 useradd     - create new user account 
 userdel      - delete user account
 mount        - mount file system 
 umount      - unmount file system 
 df              - show disk space usage 
 cp              - copy file or directory
 mv             - move file or directory
 rm             - remove file or directory
 pwd           - show current position
 mkdir         - create directory 
 rmdir          -  remove directory
 less             - display file contents pagewise
 ps               - show process status
 head           - show first lines
 tail              - show last lines
 grep            - show lines matching

 chmod        - change file mode, add or remove permission  
 chown        - change owner of the file
 :q                - quit
 :wq             - save and quit
 :q!              - force quit without saving
 shutdown   - shutdown computer



Viewing permissions

#ls -l

Database login

#mysql -u username -ppassword dbname

Dropping database And create in same name

#drop database dbname;

#create database dbname;

Show Tables


#Show tables

Permission for myDoc.txt 644

#chmod 644 myDoc.txt



Base Url Changing

#update core_config_data set value = 'http://domainname.com/' where path like '%base_url%';

Force Remove files

#rm -rf

in folder permission for all

#chmod 0755 . -R

Changing group ownership

#chgrp new_group some_file

Changing file ownership

#chown you some_file

Bulk chmod

#find directory -type d -exec chmod 755 {} +

#find directory -type f -exec chmod 644 {} +



DB setup system
update base url in the database

go to mysql prompt

#use database_name;

#update core_config_data set value = 'http://baseurlofthesite.com/' where path like '%base_url%';

create a database backup from terminal

mysqldump -u username -ppassword dbname [tablename - optional] > filename.sql

restore a database backup from terminal

mysql -u username -ppassword dbname [tablename - optional] < filename.sql

you can add nohup in front of a linux command, to make it no-hangup, once nohup is mentioned, even if the ssh session is broken ( if the internet connection is cut off, or the pc crashes) the server command will continue to run. nohup will output all the output to a file called nohup.out.

if you add an ‘&’ to the end of a command, a background process will be allocated to the command, and you can work with the terminal.

so, for any of the above commands (other than sql commands ), it is recommended to use the command as

#nohup &