/, this indicates an absolute file path. For example,
cd /changes into the root directory, and
cd /var/logchanges into the log directory - no matter what directory you're currently in.
ls -la path/
head -n 100 file.txt
tail -n 100 file.txt
nanoto create/edit a file
Use Ctrl+X to exit
rm -r path/
sudo ln -s <file-name> <link-name>
tar -czvf archive.tar.gz /path
tar -xzvf archive.tar.gz -C /path
For this command, you can use the
--strip-components=n flag to strip
n subdirectory paths from the files in the original archive.
To see the current owner and permissions for all files in a directory, use the
ls -l command.
$ ls -l /var/repo/userfrosting.git total 44 -rwxrwxr-x 1 alex alex 478 Feb 16 02:04 applypatch-msg.sample -rwxrwxr-x 1 alex alex 896 Feb 16 02:04 commit-msg.sample -rwxr-xr-- 1 alex alex 138 Feb 22 02:18 post-receive -rwxrwxr-x 1 alex alex 189 Feb 16 02:04 post-update.sample -rwxrwxr-x 1 alex alex 424 Feb 16 02:04 pre-applypatch.sample -rwxrwxr-x 1 alex alex 1642 Feb 16 02:04 pre-commit.sample -rwxrwxr-x 1 alex alex 1239 Feb 16 02:04 prepare-commit-msg.sample -rwxrwxr-x 1 alex alex 1348 Feb 16 02:04 pre-push.sample -rwxrwxr-x 1 alex alex 4898 Feb 16 02:04 pre-rebase.sample -rwxrwxr-x 1 alex alex 3610 Feb 16 02:04 update.sample
The first part of each line contains a
-, followed by three sets of three characters each. The first set of three tells you the owning user's permissions, the second set tells you the owning group's permissions, and the last set tells you the permissions for "other" users. "Other" users means any other Ubuntu user account on your server.
The next pieces of significant information are the name of the owning user and owning group. This is important, because Unix permissions are always defined relative to the owning user and owning group.
For example, let's look at this entry:
-rwxr-xr-- 1 alex alex 138 Feb 22 02:18 post-receive
We can see that the owning user is
alex, and the owning group is also
alex (Whenever you create a user in Linux, it automatically creates a group of the same name).
Then we have the following permissions:
rwx. The owning user (
alex) has full read, write, and execute permissions for this file.
r-x. The owning group (
alex) has read and execute permissions for this file.
r--. Other users only have read permissions for this file.
sudo chown <user>:<group> file.txt
sudo chmod u+r,g+r,o-w file.txt
o refer to the owning user, owning group, and other users, respectively. The
+ symbol means that we are adding permissions (use
- instead to remove permissions). The symbols afterwards are the permissions we are adding/removing. They can be any combination of
w (write), and
When new files are created in Unix, they get their permissions primarily from the file mode creation mask, also known as the umask.
If we want to change how permissions are set on newly created files in a directory (for example, when pushed there by
git), we can use
sudo setfacl -d -m g::rwx /my/path
-d indicates default permissions, and
-m g::rwx says to grant read, write, and execute permissions for the owning group (
g) on any new files created in the directory.
Just as with
chmod, you can use
u for the owning user, or
o for "all other users".
apt-get install <package-name>
apt-get upgrade <package-name>
apt-get remove <package-name>
ps aux | grep "<description>"
This will display a list of matching processes, along with their process id (pid).
kill <pid>. If that doesn't work, try
kill -9 <pid>.
||Home directory for web applications.|
||Default directory for most logs.|
||Physical location of configuration files for nginx.|
||Symbolic links to 'enabled' nginx config files.|
||Physical location of LE certificate files.||Default only accessible to root|
||Symbolic links to current LE certificate files.||Default only accessible to root|
||Renewal scripts for LE certificates.||Default only accessible to root|
root: The root user. Has the highest level of privileges.
www-data: The default account under which
backup: The "backup" user account.