Skip to content

2_Linux_Tips

Arseni1919 edited this page Jul 31, 2025 · 3 revisions

🏠 Home

Linux Tips

A collection of useful commands and tips for working with Linux.

File and Directory Management

Viewing Directory Trees

To display the directory structure as a tree:

tree -L 2
  • -L 2: Limits the depth to 2 levels.
  • --prune: Hides empty folders.

Checking Disk Space

To see how much space the current directory is using:

df

Moving and Copying Files

The syntax for mv (move) and cp (copy) is the same. The first argument is the source, and the second is the destination.

# Move a file to the parent directory's "Folder"
mv file.png ../Folder

# Copy a file to the parent directory's "Folder"
cp file.png ../Folder

Opening Files and Directories

To open a directory (or file) with the default application:

open ~/ros2_ws/

Opening Files with Administrator Permissions

To open the file manager with root privileges (be careful!):

sudo nautilus

Removing Files

To permanently delete a file:

rm filename.txt

Permissions

Making a File Executable

To grant a file execute permissions, allowing it to be run as a script:

chmod +x filename.py

System Management

Shutting Down or Restarting

# Power off the computer
sudo poweroff

# Reboot the computer
sudo reboot

System Resource Monitoring

To check system statistics like CPU and memory usage in real-time:

htop

Cleaning APT Cache

To see what will be cleaned from the APT package cache:

sudo apt-get -s clean

To perform the cleaning and free up space:

sudo apt-get clean

Terminal and Shell

Editing the .bashrc File

The .bashrc file, located in your home directory, contains shell configurations. To edit it:

gedit ~/.bashrc

Searching Command History

To search for a previously used command in your terminal history: Press Ctrl + R and start typing the search term.

Understanding the PATH Variable

The colon (:) is used as a delimiter to concatenate (join) paths in environment variables like PATH.

This example prepends a new directory to the PATH, so the system will look in /opt/ros/indigo/bin first when searching for executables:

export PATH="/opt/ros/indigo/bin:$PATH"

🏠 Home