The italic text is to be replace by the correct values.
- 1 Useful commands
- 1.1 Install upgrades
- 1.2 Reboot whole machine
- 1.3 mysql command lines
- 1.4 Error 500 debugging
- 1.5 To list the files last modified in reversed order
- 1.6 Remove a whole director, including all its content
- 1.7 32 bits or 64 bits?
- 1.8 Check performance statistics of server
- 1.9 How to make a tar archive on Ubuntu
- 1.10 Extracting the contents of a tar archive
- 1.11 How to solve the Dropbox error message "Unable to monitor filesystem. Please run: echo 100000..."
sudo apt-get upgrade
Reboot whole machine
mysql command lines
Connect to a db with mysql command line tool (phpmyadmin isn’t very secure)
mysql databaseName --user=theuser --password=thepassword
There is a default database for meta information about all databases:
mysql information_schema --user=rootuser --password=rootpassword
Once connected, standard sql can be run.
List all the databases:
Error 500 debugging
When a PHP page gives an error 500, look at the Apache error.log file to see the full details of the error message.
cd /var/log/apache2 tail -f error.log
The tail will only show the last few lines of the file and will update it live, so the same error can be reproduced by reloading the page that caused an error 500 and the error message can therefore be tracked more easily.
More about error logs
To list the files last modified in reversed order
When faced with a long list of files, it's useful to list them in reverse order of date modified, so that the last files on the list are the most recently modified ones.
Remove a whole director, including all its content
sudo rm -R path/
Note: Be very careful with the rm command. It is easy to delete the wrong thing and there is no "undo" with this command.
32 bits or 64 bits?
To find out if Linux is 32bits or 64bits, run
Check performance statistics of server
When the server is slow or websites are not responsive, start looking for spikes or unusual patterns with:
How to make a tar archive on Ubuntu
To construct a "tarball" that contains copies of all the files in a particular directory subtree:
Use the cd command to change your current working directory to the parent directory of the root directory of the subtree you want to archive. For example, if you want to build a tarball of a directory whose pathname is /u/gertrude/rain/pics/, you would use this command:
Pick a name for the tarball that ends in .tgz. In the example, we might call the tarball rainpics.tgz. Build the tarball with this command:
tar -cvzf name.tgz subdir
where subdir is the name of the subdirectory you want to save. To continue the example, this command would be:
tar -cvzf rainpics.tgz pics
The -c option tells tar to create an archive. The v option tells it to write out the names of the files on your screen as it saves them, so you can be sure it is including everything you want. The z option specifies that the file should be compressed, to save space. The f option instructs tar to use the next name (in the example, rainpics.tgz) for the tarball it is building.
The last argument is the name of the directory subtree to be saved. You could use an absolute path name here, but it is not recommended, because you may be moving the tarball to a system that has different directories. That's why we recommend you use a relative path name here.
Once your tarball file is completed, you can move or copy it elsewhere on the system, or to a different system altogether.
Extracting the contents of a tar archive
If you would like to extract all the files from a "tarball" (tar archive) file, made with a relative pathname, and with file compression turned on (as recommended in our procedure for building tarballs), use this procedure.
If you are not sure what is in the tarball, you can list its contents. Use the cd command to change your current working directory to the parent directory under which you want to place the extracted files. For example, if you want the extracted directory subtree to live inside directory /usr/meteor/data, you would use the command:
Move or copy the tarball file to that directory using the Unix mv, cp, or sftp commands. Extract the subtree using this command:
tar -xvzf filename
For example, if you have a tarball file named rainpics.tgz, you would use this command to extract its contents:
tar -xvzf rainpics.tgz
After this procedure, the tarball will remain where you have placed it, and all the files within it will reside in or below the directory to which you extracted it.
In the example, if the rainpics.tgz tarball was made with relative pathname pics, the example command would put all of the extracted files at path /usr/meteor/data/pics and its subdirectories if any.
How to solve the Dropbox error message "Unable to monitor filesystem. Please run: echo 100000..."
Unable to monitor filesystem. Please run: echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches and restart Dropbox to correct the problem.
sudo vi /etc/sysctl.conf
Add just one line of code to the end of the file and save it:
fs.inotify.max_user_watches = 100000
Reboot computer to apply settings and restart Dropbox.
If you don't have Dropbox yet, download Dropbox with my referral link which will give me a bit of extra free space (thanks!).
Source of this solution: Paul Philippov blog