Helpful Ubuntu Shell Commands

Below you will find a variety of common Linux commands. My distribution of choice is Ubuntu Server, so all commands will work on Ubuntu and Debian Linux.

Many of the following commands should work for other Linux distributions such as Redhat as well, although some commands are different.

Helpful Ubuntu Shell Commands

Make a tarball archive file with the following command.

tar -czvf tarball-name.tgz directory-name


tar -czvf archive.tgz archive

Extract a tarball archive file with the following command.

tar -xzvf file name


tar -xzvf archive.tgz

Truncate a file.

> /path/to/file/filename

Example: Truncate Mail for a certain user.

> /var/mail/username

Clear filesystem cache, dentries, and inodes.

echo 3 > /proc/sys/vm/drop_caches

##Remove a Service from System Startup.

update-rc.d -f service name remove


update-rc.d -f nginx

Add a Service to System Startup

update-rc.d service name defaults


update-rc.d nginx defaults

Add a Service to Startup with a specific priority level

update-rc.d service name defaults priority level


update-rc.d nginx defaults 75

##Find all packages installed for a specific service

dpkg -l | grep service name


dpkg -l | grep maria

Remove specific packages installed for a service.

Some might remain after apt-get remove, or were installed differently.
apt-get purge service name


apt-get purge mariadb-server-5.5

Secure your Drupal files and folders with a few simple commands.

Thanks Greggles!

Replace greg with your username.

cd /path_to_drupal_installation
chown -R greg:www-data .
find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
find . -type f -exec chmod u=rw,g=r,o= '{}' \;