Useful Fedora Linux Commands
A comprehensive guide to essential commands for managing your Fedora Linux system.
Network Share Management
Mounting SMB/CIFS Shares
Install required packages:
sudo dnf install cifs-utilsCreate a mount point:
sudo mkdir -p /mnt/shareMount SMB share temporarily:
sudo mount -t cifs //SERVER_IP/share_name /mnt/share -o username=USERNAMEMount with additional options:
sudo mount -t cifs //SERVER_IP/share_name /mnt/share -o username=USERNAME,uid=1000,gid=1000,file_mode=0755,dir_mode=0755Mount guest share (no authentication):
sudo mount -t cifs //SERVER_IP/share_name /mnt/share -o guest,uid=1000,gid=1000Unmount a share:
sudo umount /mnt/sharePermanent mount (add to /etc/fstab):
//SERVER_IP/share_name /mnt/share cifs credentials=/home/USER/.smbcredentials,uid=1000,gid=1000 0 0Create credentials file ~/.smbcredentials:
username=YOUR_USERNAME
password=YOUR_PASSWORDSet proper permissions:
chmod 600 ~/.smbcredentialsMounting NFS Shares
Install NFS utilities:
sudo dnf install nfs-utilsMount NFS share:
sudo mount -t nfs SERVER_IP:/export/path /mnt/nfsFile Search and Management
Finding Files with find
List all files in a directory:
find /mnt/movies -type fSave file list to text file:
find /mnt/movies -type f > file_list.txtList files with detailed information:
find /mnt/movies -type f -lsFind specific file types (videos):
find /mnt/movies -type f \( -name "*.mp4" -o -name "*.mkv" -o -name "*.avi" \)Find files by name pattern:
find /path -name "pattern*"
find /path -iname "pattern*" # Case-insensitiveFind files larger than a specific size:
find /path -type f -size +1G # Files larger than 1GB
find /path -type f -size -100M # Files smaller than 100MBFind files modified in the last N days:
find /path -type f -mtime -7 # Modified in last 7 days
find /path -type f -mtime +30 # Modified more than 30 days agoFind and execute commands on results:
find /path -type f -name "*.log" -exec rm {} \; # Delete log files
find /path -type f -name "*.txt" -exec wc -l {} \; # Count lines in text filesFind empty files and directories:
find /path -type f -empty # Empty files
find /path -type d -empty # Empty directoriesFind files by permissions:
find /path -type f -perm 0777 # World-writable files
find /path -type f -perm /u+x # Executable by ownerCount files in directory:
find /path -type f | wc -lFind duplicate files by size:
find /path -type f -printf "%s %p\n" | sort -nUsing locate (faster alternative)
Update database:
sudo updatedbSearch for files:
locate filename
locate -i filename # Case-insensitiveUsing grep for content search
Search for text in files:
grep -r "search_term" /path # Recursive search
grep -ri "search_term" /path # Case-insensitive
grep -rn "search_term" /path # Show line numbers
grep -rl "search_term" /path # Show only filenamesSystem Package Management
DNF Package Manager
Update system:
sudo dnf update
sudo dnf upgrade # Same as updateSearch for packages:
dnf search package_nameInstall packages:
sudo dnf install package_name
sudo dnf install package1 package2 package3Remove packages:
sudo dnf remove package_name
sudo dnf autoremove # Remove unused dependenciesList installed packages:
dnf list installed
dnf list installed | grep package_nameShow package information:
dnf info package_nameCheck for available updates:
dnf check-updateClean package cache:
sudo dnf clean allList repositories:
dnf repolistEnable/disable repositories:
sudo dnf config-manager --set-enabled repo_name
sudo dnf config-manager --set-disabled repo_nameSystem Information
System version:
cat /etc/fedora-release
hostnamectlKernel version:
uname -r
uname -a # All system informationCPU information:
lscpu
cat /proc/cpuinfoMemory information:
free -h
cat /proc/meminfoDisk usage:
df -h # Human-readable format
df -h / # Specific partitionDirectory size:
du -sh /path/to/directory
du -h --max-depth=1 /path # Subdirectories sizeSystem uptime:
uptimeLogged in users:
who
w # More detailed informationHardware information:
lshw # Requires sudo
lspci # PCI devices
lsusb # USB devicesFile Operations
Copy files:
cp source destination
cp -r source_dir dest_dir # Recursive (directories)
cp -p source dest # Preserve attributesMove/rename files:
mv source destinationRemove files:
rm file
rm -r directory # Recursive
rm -rf directory # Force recursive (use carefully!)Create directories:
mkdir directory_name
mkdir -p parent/child/grandchild # Create parent directoriesCreate empty file:
touch filenameChange permissions:
chmod 755 file # rwxr-xr-x
chmod +x script.sh # Add execute permission
chmod -R 644 directory # RecursiveChange ownership:
sudo chown user:group file
sudo chown -R user:group directoryCreate symbolic link:
ln -s /path/to/original /path/to/linkArchive and compress:
tar -czf archive.tar.gz /path/to/directory # Create gzip archive
tar -xzf archive.tar.gz # Extract gzip archive
tar -cjf archive.tar.bz2 /path/to/directory # Create bzip2 archive
tar -xjf archive.tar.bz2 # Extract bzip2 archiveZip operations:
zip -r archive.zip directory
unzip archive.zipProcess Management
List running processes:
ps aux
ps aux | grep process_nameReal-time process viewer:
top
htop # Better alternative (may need to install)Kill processes:
kill PID
kill -9 PID # Force kill
killall process_name # Kill by name
pkill process_name # Kill by patternBackground and foreground jobs:
command & # Run in background
jobs # List background jobs
fg %1 # Bring job 1 to foreground
bg %1 # Resume job 1 in backgroundSystem resource usage:
vmstat # Virtual memory statistics
iostat # I/O statisticsNetwork Commands
Network interfaces:
ip addr show
ip link show
nmcli device status # NetworkManagerTest connectivity:
ping hostname
ping -c 4 hostname # Send only 4 packetsDNS lookup:
nslookup domain.com
dig domain.com
host domain.comNetwork connections:
ss -tuln # All listening TCP/UDP ports
ss -tunap # All connections with process info
netstat -tuln # Alternative (older command)Download files:
wget URL
curl -O URL # Save with original filename
curl -o filename URL # Save with custom filenameCheck open ports:
sudo ss -tulpn
sudo netstat -tulpnFirewall management:
sudo firewall-cmd --list-all # List all rules
sudo firewall-cmd --add-port=8080/tcp --permanent # Open port
sudo firewall-cmd --reload # Apply changesDisk Management
List block devices:
lsblk
lsblk -f # Include filesystem typePartition information:
sudo fdisk -l
sudo parted -lMount/unmount:
sudo mount /dev/sdX1 /mnt/mountpoint
sudo umount /mnt/mountpointCheck filesystem:
sudo fsck /dev/sdX1 # Filesystem check (unmounted only!)Format filesystem:
sudo mkfs.ext4 /dev/sdX1 # Format as ext4
sudo mkfs.xfs /dev/sdX1 # Format as XFSDisk usage by directory:
ncdu /path # Interactive disk usage analyzer (may need to install)Additional Useful Commands
System logs:
journalctl # View systemd logs
journalctl -f # Follow logs in real-time
journalctl -u service_name # Logs for specific service
journalctl --since "1 hour ago"Service management:
sudo systemctl start service_name
sudo systemctl stop service_name
sudo systemctl restart service_name
sudo systemctl status service_name
sudo systemctl enable service_name # Start on boot
sudo systemctl disable service_nameText file viewing:
cat file # View entire file
less file # Paginated view
head -n 20 file # First 20 lines
tail -n 20 file # Last 20 lines
tail -f file # Follow file updatesCommand history:
history # Show command history
history | grep search_term
!123 # Execute command number 123
!! # Execute last commandScreen/Tmux (terminal multiplexer):
screen # Start new session
screen -ls # List sessions
screen -r # Reattach to session
# Ctrl+A, D to detachTips and Tricks
- Use
Tabfor command and filename auto-completion - Use
Ctrl+Rto search command history - Use
Ctrl+Cto cancel current command - Use
man command_nameto view manual pages - Use
command --helpfor quick command help - Use
aliasto create command shortcuts:alias ll='ls -la' - Add frequently used aliases to
~/.bashrcor~/.bash_aliases