Ubuntu Basics: Getting Started with Linux for AI Development
Welcome to the second part of our Linux AI Development Course. Now that you have successfully installed Ubuntu, it's time to learn the basics of navigating and using your new operating system. This guide is designed for beginners with little to no prior Linux experience, providing you with the essential knowledge needed for AI development work.
Understanding the Ubuntu Desktop Environment
When you first log into Ubuntu, you'll be greeted by the GNOME desktop environment. Let's explore its key components:
The Desktop Layout
The Ubuntu desktop is designed to be clean and intuitive. Here are the main elements you'll interact with:
The Dock
Located on the left side of the screen by default, the Dock contains icons for your favorite and currently running applications. You can click on these icons to launch or switch to applications. To add an application to the Dock, right-click on its icon while the application is running and select "Add to Favorites."
Activities Overview
Clicking on the "Activities" button in the top-left corner or pressing the Super key (Windows key) opens the Activities Overview. This view shows all open windows and provides access to the application launcher and workspace switcher.
Top Bar
The bar at the top of the screen contains the Activities button, clock, and system indicators (network, sound, battery, etc.). Clicking on the system indicators opens a menu with quick settings and notifications.
Application Launcher
In the Activities Overview, you can start typing to search for applications, files, and settings. You can also click on the grid icon at the bottom of the Dock to see all installed applications.
Workspaces
Ubuntu allows you to organize your work across multiple virtual desktops called workspaces. In the Activities Overview, workspaces are displayed on the right side of the screen. You can drag windows between workspaces to organize your work.
Customizing Your Desktop
Ubuntu offers various customization options to make your desktop more comfortable and efficient:
Settings
Access the Settings application by clicking on the system indicators in the top-right corner and selecting the gear icon. Here, you can adjust display settings, change the background, configure network connections, and more.
Appearance
In Settings > Appearance, you can switch between light and dark themes, adjust the position of the Dock, and change its behavior.
Extensions
GNOME extensions add functionality to your desktop. Install the "GNOME Extensions" application from the Software Center to browse and manage extensions.
File System Navigation
Understanding the Linux file system structure is crucial for effective system navigation and management.
The Linux File System Hierarchy
Unlike Windows with its drive letters (C:, D:, etc.), Linux uses a unified file system where everything is organized under a single root directory, denoted by a forward slash (/). Here's an overview of the main directories:
- /home: Contains user home directories. Your personal files are stored in /home/username/ (where "username" is your login name).
- /usr: Contains most of the user utilities and applications.
- /etc: Contains system-wide configuration files.
- /var: Contains variable data files, such as logs and temporary files.
- /bin and /sbin: Contain essential system binaries (executable programs).
- /tmp: Contains temporary files that are typically cleared on reboot.
- /opt: Often used for optional or third-party software.
- /media and /mnt: Used as mount points for removable media and temporarily mounted file systems.
Navigating with the Files Application
Ubuntu comes with a graphical file manager called "Files" (also known as Nautilus). To open it, click on the Files icon in the Dock or search for "Files" in the Activities Overview.
Basic Navigation
The Files application works similarly to file explorers in other operating systems. You can:
- Double-click on folders to open them
- Use the back and forward buttons to navigate through your browsing history
- Use the path bar at the top to see your current location and navigate to parent directories
- Use the sidebar on the left for quick access to common locations
Creating and Managing Files and Folders
Right-click in an empty area to create new folders or files. Right-click on existing items to rename, delete, or see their properties.
Search
Use the search button in the top-right corner to find files and folders.
Keyboard Shortcuts
Learn these useful shortcuts to improve your efficiency:
- Ctrl+N: New window
- Ctrl+T: New tab
- Ctrl+H: Show hidden files
- Ctrl+L: Edit location (enter a path directly)
- F2: Rename selected item
File Permissions
Linux uses a permission system to control who can read, write, or execute files. Understanding permissions is important for security and proper system management.
Each file and directory has three sets of permissions:
- Owner permissions: What the file owner can do
- Group permissions: What users in the file's group can do
- Others permissions: What all other users can do
For each set, there are three possible permissions:
- Read (r): Permission to read the file or list the directory contents
- Write (w): Permission to modify the file or create/delete files in the directory
- Execute (x): Permission to run the file as a program or access files in the directory
To view permissions in the Files application, right-click on a file or folder, select "Properties," and go to the "Permissions" tab.
The Terminal: Your Powerful Tool
While Ubuntu provides a user-friendly graphical interface, the Terminal is a powerful tool that gives you direct access to the system. Many AI development tasks are more efficiently performed through the Terminal.
Opening the Terminal
You can open the Terminal in several ways:
- Press Ctrl+Alt+T
- Search for "Terminal" in the Activities Overview
- Right-click on an empty area in the Files application and select "Open in Terminal"
Basic Terminal Navigation
When you open the Terminal, you'll see a prompt that typically shows your username, computer name, and current directory, followed by a dollar sign ($).
Here are some essential commands for navigating the file system:
pwd (Print Working Directory)
Shows your current location in the file system.
pwd
ls (List)
Lists files and directories in the current directory.
ls
Add options to modify the output:
ls -l # Long format with details
ls -a # Show hidden files
ls -la # Combine options
cd (Change Directory)
Navigate to different directories.
cd /path/to/directory # Navigate to a specific directory
cd ~ # Navigate to your home directory
cd .. # Navigate up one level
cd - # Navigate to the previous directory
mkdir (Make Directory)
Create new directories.
mkdir directory_name
touch
Create empty files.
touch filename
cp (Copy)
Copy files and directories.
cp source destination # Copy a file
cp -r source_dir destination # Copy a directory and its contents
mv (Move)
Move or rename files and directories.
mv source destination # Move a file or directory
mv oldname newname # Rename a file or directory
rm (Remove)
Delete files and directories.
rm filename # Delete a file
rm -r directory_name # Delete a directory and its contents
cat
Display file contents.
cat filename
less
View file contents with pagination.
less filename
(Press 'q' to exit)
grep
Search for patterns in files.
grep "search_term" filename
man
Display the manual page for a command.
man command_name
Terminal Tips and Tricks
Tab Completion
Press Tab to automatically complete commands and file paths. Double-tap Tab to see available options.
Command History
Use the up and down arrow keys to navigate through previously used commands.
Clearing the Screen
Type clear
or press Ctrl+L to clear the Terminal screen.
Stopping Commands
Press Ctrl+C to stop a running command.
Running with Elevated Privileges
Use sudo
before a command to run it with administrative privileges.
sudo command
You'll be prompted for your password.
Package Management in Ubuntu
Ubuntu uses the APT (Advanced Package Tool) system for managing software. Understanding package management is essential for installing and updating software, including AI development tools.
Software Center
The Ubuntu Software Center provides a graphical interface for finding and installing applications. You can open it from the Dock or by searching for "Software" in the Activities Overview.
Browse categories, search for specific applications, and click "Install" to add them to your system. The Software Center also handles updates for installed applications.
APT Command Line Tools
For more control and efficiency, you can use APT commands in the Terminal:
Update Package Lists
Refresh the list of available packages.
sudo apt update
Upgrade Installed Packages
Install available updates for all installed packages.
sudo apt upgrade
Install Packages
Install new software packages.
sudo apt install package_name
You can install multiple packages at once:
sudo apt install package1 package2 package3
Remove Packages
Uninstall software packages.
sudo apt remove package_name
Search for Packages
Find packages by name or description.
apt search keyword
Show Package Information
Display detailed information about a package.
apt show package_name
Autoremove
Remove packages that were automatically installed but are no longer needed.
sudo apt autoremove
Managing PPAs and Third-Party Repositories
Sometimes, you'll need to add Personal Package Archives (PPAs) or other third-party repositories to install software not available in the official Ubuntu repositories.
Adding a PPA
sudo add-apt-repository ppa:repository_name
sudo apt update
Removing a PPA
sudo add-apt-repository --remove ppa:repository_name
sudo apt update
System Monitoring and Management
Keeping track of system resources is important, especially for resource-intensive AI development tasks.
System Monitor
Ubuntu includes a graphical System Monitor application that shows CPU, memory, and network usage. You can also view and manage running processes.
To open System Monitor, search for it in the Activities Overview or run:
gnome-system-monitor
Terminal-Based Monitoring Tools
top
Display real-time system statistics and running processes.
top
(Press 'q' to exit)
htop
An improved version of top with a more user-friendly interface.
sudo apt install htop
htop
(Press 'q' to exit)
df
Check disk space usage.
df -h # -h for human-readable format
free
Display memory usage.
free -h
ps
List running processes.
ps aux
Managing Services
Services are background programs that run automatically. You can manage them using the systemctl
command:
Check Service Status
systemctl status service_name
Start a Service
sudo systemctl start service_name
Stop a Service
sudo systemctl stop service_name
Enable a Service to Start at Boot
sudo systemctl enable service_name
Disable a Service from Starting at Boot
sudo systemctl disable service_name
Text Editing in Ubuntu
Text editors are essential tools for programming and configuration. Ubuntu offers several options:
Graphical Text Editors
gedit
Ubuntu's default text editor. Simple and user-friendly.
gedit filename
Visual Studio Code
A powerful, extensible code editor popular among developers.
sudo apt install code
code filename
Terminal-Based Text Editors
nano
A simple, beginner-friendly editor.
nano filename
Common shortcuts:
- Ctrl+O: Save file
- Ctrl+X: Exit
- Ctrl+G: Help
vim
A powerful, modal text editor with a steeper learning curve.
vim filename
Basic vim usage:
- Press 'i' to enter insert mode
- Edit text
- Press Esc to exit insert mode
- Type ':w' to save
- Type ':q' to quit
- Type ':wq' to save and quit
emacs
Another powerful editor with extensive customization options.
emacs filename
Conclusion
This guide has covered the essential basics of using Ubuntu for AI development. You've learned how to navigate the desktop environment, use the Terminal, manage packages, monitor system resources, and more. These skills form the foundation for your journey into AI development on Linux.
In the next guide, we'll explore how to install and use Claude Coder, a powerful AI development tool that will enhance your productivity and capabilities.
Remember that learning Linux is an ongoing process. Don't be afraid to experiment, make mistakes, and learn from them. The more you use Ubuntu, the more comfortable and proficient you'll become.