2.4. Files and directories#

This section includes an introduction to your home directory, files, directories, and their functions, the root filesystem and a how-to on transferring files between systems.

2.4.1. Your home directory#

When you log in to the desktop and open Files, it will display your home directory (Fig. 33).

The following directories will be present in your home directory by default: Desktop, Documents, Downloads, Music, Pictures, Public, Templates, and Videos.

../../_images/home-directory.png

Fig. 33 Home directory#

Notes#

/home/user#

The complete (or absolute) path to your home directory will be of the form /home/user, where user is your username on the system.

$HOME#

The HOME environment variable will automatically be set to the complete path to your home directory in the filesystem.

Hence, you can substitute /home/user with $HOME in your commands or scripts.

2.4.2. Hidden files and directories#

In addition to the default directories mentioned earlier, there are hidden files and directories in home directory (Fig. 34). They have a dot (.) character at the beginning of their file name.

../../_images/hidden-directories.png

Fig. 34 Hidden files and directories in home directory#

You can view (or hide) these files using the following menu entry in file manager:

View ‣ Show Hidden Files

Alternatively, you can use the Ctrl + h keyboard shortcut.

2.4.3. Important files in home directory#

.bashrc#

This is the configuration file used by Bash, the default shell for user accounts. You will mostly use this file, when you need to set or modify environment variables like PATH.

.bash_aliases#

You can use the .bash_aliases file to set aliases for commands.

For example, here is a commonly used alias:

alias l='ls -l'

This means when you type l at the command-line, the bash shell will execute ls -l, which will output a long listing of files, instead of the default.

Note

To learn more about the ls command, read the List files and directories: ls section.

2.4.4. File and directory names are case-sensitive#

One thing you will need to remember is that file and directory names in Linux are case-sensitive.

For example, a file named:

sequence.txt

is different from:

Sequence.txt

Similarly, Documents and documents are two different directories.

Both these files or directories mentioned above, can exist in the same directory and can have different contents.

2.4.5. Accessing the root filesystem#

To access the root filesystem (/), click on File System in the sidebar of file manager (Fig. 35).

../../_images/file-system.png

Fig. 35 Click on File System entry to access the root filesystem#

Directories under / and their functions#

/etc

­— stores configuration files of applications

/home

­— contains home directories of users

/media

­— locations where devices like external disks will be mounted i.e., made available

/root

­— home directory of root user (administrator)

/tmp

­— temporary files created by applications

/usr

­— applications and libraries are installed here along with their data and documentation

/var

­— storage for log files, application cache, databases etc.,

Root file system and root home directory are different#

/ is the root filesystem#

All users on the system can access files and directories here, provided they have the appropriate permissions.

/root is home directory of root#

Only root will have access to it.

2.4.6. Transferring files between systems#

One useful feature of Files is the ability to connect to remote systems using protocols like SSH, FTP, SMB and Webdav. Once connected, you can transfer files from your Linux desktop to the remote system or vice-versa.

To connect to a remote system, use the following menu entry in Files (Fig. 36):

File ‣ Connect to Server

../../_images/files-connect.png

Fig. 36 Connect to Server option in Files#

Connecting to an SSH server#

Open File ‣ Connect to Server and follow the steps below (Fig. 37):

  1. In the field corresponding to Server, enter the domain name or IP address of the server you are connecting to

  2. Port 22 is the default for SSH, so you do not need to change that usually

  3. From the Type drop-down box, select SSH

  4. Under Folder, you can specify a directory (optional) to open, once connection is successful

  5. Enter the username and password of your account on the server

  6. Click on the Connect button

../../_images/files-connect-ssh.png

Fig. 37 Connecting to an SSH server#

Once the remote directory is open in Files, you can start transferring files from your desktop or vice-versa.

Comments