Useful commands for Debian or Ubuntu Linux

Linux is an operating system. It allows the configuration and the execution of all other programs on the server. It is available in several distributions including Debian and Ubuntu which deliver the best compromise between simplicity, security and robustness.

This post presents some useful commands for Debian or Ubuntu Linux.

Display the contents of a file

cat myfile

Change file or directory permissions

Commonly 644 for files and 755 for directories.

chmod 644 myelement

Change file or directory owner

chown myuser:mygroup myelement

Schedule tasks

crontab -e

Get disk space usage

df -h

Install or remove locales

dpkg-reconfigure locales

Change directories permissions recursively

Commonly 755 for directories.

find /home/user -type d -exec chmod 755 {} \;

Change files permissions recursively

Commonly 644 for files.

find /home/user -type f -exec chmod 644 {} \;

Create a directory

mkdir mydirectory

Edit a file

nano myfile

Keep a program running after the user logout

nohup ./myprogram > /dev/null &

Change user’s pasword

passwd myuser

Shut down the server


Check if a program is running

ps aux | grep myprogram

Reboot the server


Replace a string with another in multiple files

sed -i 's/old/new/g' *.txt

Run a script at server startup

The script must be in /etc/init.d and must have execution permission.

update-rc.d myscript defaults

Remove a script from server startup

update-rc.d -f myscript remove

Create a user and his home directory

The user’s home directory is located in /home.

useradd -m myuser

» Install and set up Linux Debian 7
» Install and set up a web server on Debian or Ubuntu Linux

Leave a Reply

Your email address will not be published. Required fields are marked *