chown -R user:group directoryorfilename
Change Permissions Recursively:
***CAUTION: this has in the past deleted the entire contents of a folder when used with a directory name
chmod -R XXX DirectoryOrFilename
Get All Users:
getent passwd
Get All Groups:
getent group
Run commands as a superuser (if getting "Cannot run with sudo"):
(command) --allow-root
List current (working) directory:
pwd
Get file size of 1st level of folders in root directory:
ls
List contents of directory:
du -h --max-depth=1 /
Get size and avail space on drive
df -h
Get file size of each folder:
du -sh *
List files in order by size
ls -lh -S
MySQL Related Commands
Check mysql status:
/etc/init.d/mysql status
Restart mysql:
sudo service mysql restart
Export database to sql file:
mysqldump -u [uname] -p database_name > filename.sql
Restore database from sql file:
mysql -u username -p database_name < file.sql
Access MySQL shell from linux commandline:
mysql -u root -p
Once in mysql, you can use these commands
List databases:
SHOW DATABASES;
List users:
SELECT User FROM mysql.user;
Create a new user with remote access enabled:
GRANT ALL ON DatabaseName.* TO UserName@’1.2.3.4’ IDENTIFIED BY ‘PasswordHere’;
Nano Commands
Copy a line (This can be used multiple times to add lines to the buffer):
Alt-^ (Alt-Shift-6)
Paste buffer content
Ctrl-U
Go to bottom of file
Ctrl-W + Ctrl-V