Sign In
Sign In

Input/Output Redirection in Linux

Input/Output Redirection in Linux
Hostman Team
Technical writer
Linux
10.04.2025
Reading time: 8 min

One of the key principles of the UNIX philosophy is that all command-line interface (CLI) commands should accept text as input and produce text as output. Since this concept was applied in the development of UNIX (and later Linux), there are commands to receive text as input, perform an operation on it, and then produce text as output. Commands that read text input, modify it in some way, and then produce text output are sometimes called filters.

To use filter commands and work with text streams effectively, we should understand several types of redirection available with most commands: pipelines, standard output redirection, error output redirection, and input redirection.

Standard Output

When a command executes without errors, the resulting output is called standard output, also known as STDOUT. By default, this output is sent to the terminal where the command is run.

We can redirect standard output from the command so it goes to a file instead of the terminal using the greater-than symbol (>) followed by the target file. For example, the command ls ~ lists files in the home directory. To save this list to a text file:

ls ~ > /tmp/home.txt

The contents of home.txt would then look like this:

cat /tmp/home.txt

Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos

Using a single > creates a new file or overwrites an existing one. Using two greater-than symbols >> also creates a file if it doesn't exist but appends output to the end if the file already exists. For example, to append the output of the date command:

date >> /tmp/home.txt   
cat /tmp/home.txt

Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos
Sun Mar 30 07:36:02 UTC 2025

Standard Error

In Linux, when a command encounters an error, it produces output known as standard error, also called stderr or STDERR. Like standard output, it is usually sent to the same terminal. The file descriptor number for standard error is 2.

For example, trying to run:

ls /junk

Will produce:

ls: cannot access /junk: No such file or directory

Since this output goes to stderr, using just > won't redirect it:

ls /junk > output

ls: cannot access /junk: No such file or directory

To redirect error messages, use the correct file descriptor:

ls /junk 2> /tmp/ls.err

Like with standard output, > will create or overwrite the file. To append to the error log instead:

ls /junk 2>> /tmp/ls.err

Some commands produce both stdout and stderr. For example:

find /etc -name passwd

/etc/pam.d/passwd
/etc/passwd
find: '/etc/ssl/private': Permission denied

You can redirect these into two separate files:

find /etc -name passwd > /tmp/output.txt 2> /tmp/error.txt

To verify:

cat /tmp/output.txt

/etc/pam.d/passwd/etc/passwd
cat /tmp/error.txt

find: '/etc/ssl/private': Permission denied

If you don't want to display or save error messages, redirect them to /dev/null. This file acts like a trash bin where all input disappears. Any output type can be redirected there, most commonly stderr:

find /etc -name passw 2> /dev/null

/etc/pam.d/passwd
/etc/passwd

Combining Standard Output and Error

To redirect both stdout and stderr into a single file, use either of the following methods:

ls > /tmp/ls.all 2>&1
ls &> /tmp/ls.all

Both commands create the file /tmp/ls.all containing both standard output and error messages. In the first command, 2>&1 means "send stderr to the same place as stdout." The second uses &> as shorthand for "redirect all output."

Standard Input

Standard input, also known as stdin or STDIN, typically comes from the keyboard and is entered by the user running the command. While most commands can read input from files, some expect the user to type input manually using the keyboard.

One common way to use text files as standard input is by creating script files. Scripts are simple text files that are interpreted by the shell when given the appropriate permissions and start with #!/bin/sh in the first line, which tells the shell to interpret the script as standard input:

cat examplescriptfile.sh

#!/bin/sh
echo HelloWorld

When a script file is called in the command line using the ./ syntax, the shell executes all commands in the script file and returns the result to the terminal window or wherever the output is directed:

./examplescriptfile.sh

HelloWorld

In some cases, it’s useful to redirect standard input so that it comes from a file instead of the keyboard. A good example where input redirection is desirable is the tr command. The tr command translates characters by reading from standard input, converting one set of characters to another, and writing the transformed text to standard output.

For example, the following tr command takes input from the user (via keyboard) to convert all lowercase letters to uppercase:

tr 'a-z' 'A-Z'

hello
HELLO

The tr command will not stop reading from standard input unless it is terminated. You can do this by pressing Ctrl+D.

The tr command does not accept a filename as a command-line argument. To perform translation using a file as input, use input redirection. To do this, enter the command with its parameters and arguments, followed by the less-than symbol < and the file path to be used for input. For example:

cat Documents/animals.txt

1 retriever
2 badger
3 bat
4 wolf
5 eagle
tr 'a-z' 'A-Z' < Documents/animals.txt

1 RETRIEVER
2 BADGER
3 BAT
4 WOLF
5 EAGLE

Command Pipelines

Command pipelines are often used to efficiently apply filter commands. In a command pipeline, the output of one command is sent to another command as input. In Linux and most operating systems, the vertical bar | represents a pipeline between two commands.

For example, if the output of the history command is very long, you can send it to the less command to display one page at a time:

history | less

An even better example is taking the output of history and filtering it using the grep command. In the following example, the text output from history is redirected to grep as input. The grep command matches lines containing "ls" and sends the result to standard output:

history | grep "ls"

1  ls ~ > /tmp/home.txt
5  ls l> /tmp/ls.txt
6  ls 1> /tmp/ls.txt
7  date 1>> /tmp/ls.txt
8  ls /junk
9  ls /junk > output
10 ls /junk 2> /tmp/ls.err
11 ls /junk 2>> /tmp/ls.err
14 ls > /tmp/ls.all 2>&1
15 ls &> /tmp/ls.all
16 ls /etc/au* >> /tmp/ls.all 2>&1
17 ls /etc/au* &>> /tmp.ls.all
20 history | grep "ls"

Command pipelines become especially powerful when combining three or more commands. For example, view the contents of the os.csv file in the Documents directory:

cat Documents/os.csv

1970,Unix,Richie
1987,Minix,Tanenbaum
1970,Unix,Thompson
1991,Linux,Torvalds

The following command line extracts some fields from os.csv using the cut command, then sorts those lines using sort, and finally removes duplicates using uniq:

cut -f1 -d',' Documents/os.csv | sort -n | uniq

1970
1987
1991

The tee Command

The tee command splits the output of a command into two streams: one is directed to standard output (displayed in the terminal), and the other is written to a file.

The tee command is useful for logging the output of a command or script. For example, to record the execution time of a process, start with the date command and copy the output to a file timer.txt:

date | tee timer.txt

Tue Apr 2 02:21:24 UTC 2025

The timer.txt file now contains a copy of the date, the same output as shown above:

cat timer.txt

Tue Apr 2 02:21:24 UTC 2025

To append the time to the end of timer.txt, use the -a option:

date | tee -a timer.txt

Tue Apr 2 02:28:43 UTC 2025

To run multiple commands as one line, use the semicolon ; as a separator:

date | tee timer.txt; sleep 15; date | tee -a timer.txt

Tue Apr 2 02:35:47 UTC 2025
Tue Apr 2 02:36:02 UTC 2025

The command above displays and writes the first date output, pauses for 15 seconds, then displays and writes the second date output. The timer.txt file now contains a persistent execution log.

The xargs Command

Command options and parameters are typically specified directly in the command line as arguments. Alternatively, you can use the Linux xargs command to collect arguments from another input source (such as a file or standard input) and pass them to a command. xargs can be called directly and will accept any input:

xargs

Hello
There

To exit xargs, press Ctrl+C.

By default, xargs passes input to the echo command if no other command is explicitly given. After pressing Ctrl+D, xargs sends the input to echo:

Pressing Ctrl+D after exiting xargs with Ctrl+C will also exit the current shell. To send input to echo without exiting the shell, press Ctrl+D during xargs execution.

The Linux xargs command is most useful when used in a pipeline. The following example uses the touch command to create four files. The file names are 1a, 1b, 1c, and 1d, based on the output from the echo command:

echo '1a 1b 1c 1d' | xargs touch
ls

1a  1c  Desktop Downloads  Pictures  Templates  timer.txt
1b  1d  Documents  Music   Public    Videos

Conclusion

We’ve reviewed input/output stream redirection in Linux: standard output redirection, error output redirection, input redirection, and pipelines. Understanding these capabilities makes working with bash scripts easier and helps efficiently administer servers running Linux-based operating systems.

And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS.

Linux
10.04.2025
Reading time: 8 min

Similar

Linux

Creating Symbolic Links in Linux: A Step-by-Step Tutorial

Symlinks, also known as symbolic links, are like shortcuts in the Linux world. They allow you to create a new name (or link) that points to another file, directory, or any object within the file system. Their primary advantage lies in reducing redundancy by avoiding the need for multiple copies of the same file. When you have a symlink, changes made to the original file reflect across all its symbolic links. This eliminates the hassle of updating numerous copies individually. Additionally, symlinks offer a flexible way to manage access permissions. For instance, different users with directories pointing to subsets of files can limit visibility beyond what standard file system permissions allow. In essence, symlinks are indispensable for efficient file management and organization, streamlining updates and access control in complex systems. Prerequisites To follow this tutorial, you will need: A cloud server, virtual machine or computer running a Linux operating system. On Hostman, you can deploy a server with Ubuntu, CentOS or Debian in under a minute. Creating Symbolic Links with the ln Command The ln command is used to create symbolic links in Linux. Follow these steps: Open a terminal window. Navigate to the directory where you want to create the symbolic link. Use the following command syntax to create a symlink: ln -s /path/to/source /path/to/symlink Replace /path/to/source with the actual path of the file or directory you want to link, and /path/to/symlink with the desired name/location of the symlink. Understanding the ln Command Options The ln command offers various options to customize symlink creation:  -s: Creates a symbolic link.  -f: Overwrites an existing symlink.  -n: Treats symlink targets as normal files. Explore these options based on your linking needs. Creating Symbolic Links to Files To create a symlink to a file, use the ln command with the -s option. Here's an example of how you can create a symbolic link to a file using the ln command. The command below creates a symbolic link named symlink_file in the current directory, pointing to the file /path/to/file: ln -s /path/to/file /path/to/symlink_file Replace /path/to/file with the actual file path and /path/to/symlink_file with the desired symlink name. In this example, the file path is absolute. You can also create a symbolic link with a relative path. However, keep in mind that for the symlink to work correctly, anything accessing it must first set the correct working directory, or the link may appear broken. Creating Symbolic Links to Directories You can use the ln command to create a symbolic link that points to a directory. For instance, the command below creates a symbolic link called symlink_directory in the current directory, which points to the directory /path/to/directory: ln -s /path/to/directory /path/to/symlink_directory This command creates a symbolic link named symlink_directory in your current location, linking it to the /path/to/directory directory. Forcefully overwrite a symbolic link You can use the -f flag with the ln command. For example, if the path in a symlink is incorrect due to a typo or if the target has moved, you can update the link like this: ln -sf /path/to/new-reference-dir symlink_directory Using the -f flag ensures that the old symlink's contents are replaced with the new target. It also automatically removes any conflicting files or symlinks if there's a conflict. If you attempt to create a symlink without the -f flag and the symlink name is already in use, the command will fail. Verifying Symbolic Links You can display the contents of a symlink using the ls -l command in Linux: ls -l symlink_directory The output will show the symlink and its target: symlink_file -> /path/to/reference_file Here, symlink_file is the name of the symlink, and it points to the file /path/to/reference_file. ls -l /path/to/symlink The output will show the symlink and its target. Symbolic Link Best Practices Use descriptive names for symbolic links. Avoid circular links to prevent system confusion. Update symlinks if the target's location changes. Use Cases for Symbolic Links Managing Configuration Files: Linking configuration files across systems. Version Control: Symbolic linking common libraries for development projects. Data Backup: Creating symbolic links to backup directories. Potential Pitfalls and Troubleshooting Permission Issues: Ensure proper permissions for source and symlink. Broken Links: Update symlinks if target files are moved or deleted. Cross-Filesystem Links: Symlinks may not work across different filesystems. Conclusion Symlinks are valuable for streamlining file management and system upkeep. They simplify updates across multiple applications sharing a common file, reducing maintenance complexity. They also offer an alternative to directories like /etc, often requiring root access for file modifications. Developers find symlinks useful for transitioning between local testing files and production versions seamlessly. By following this tutorial, you've mastered the art of creating symbolic links in Linux. Leverage symlinks for efficient file management and customization. By the way, with Hostman, you can run your workloads on efficient NL VPS that support low latency for EU-based users. Check this out, we have plenty of budget VPS hosting options for your projects. Frequently Asked Questions (FAQ) How do you create a symbolic link in Linux?  Use the ln command with the -s flag. The syntax is ln -s [path_to_target] [path_to_link]. For example: ln -s /var/www/html/mysite ~/mysite-shortcut. What is an example of a symlink?  A desktop shortcut is the most common example. It is a small file that points to a program or document stored elsewhere on your drive, allowing you to open it without moving the original file. How do I find symbolic links in Ubuntu?  To see links in your current directory, run ls -la and look for files marked with an l permission (e.g., lrwxrwxrwx). To search for all symlinks in a directory and its subfolders, use find . -type l. How do I remove a symbolic link?  You can remove a symlink just like a regular file using rm [link_name] or unlink [link_name]. This deletes the link but leaves the original file untouched. What is the difference between a hard link and a symbolic (soft) link?  A symbolic link points to the location of a file (like a shortcut). If the original file is deleted, the link breaks. A hard link points to the actual data on the disk; even if you delete the original file name, the data remains accessible through the hard link.
19 January 2026 · 6 min to read
Linux

Linux Keyboard Shortcuts: Top Combinations for Users

Keyboard shortcuts in Linux are a great tool that can help you work more efficiently. Instead of using the mouse and navigating the menus, you can often press a couple of buttons to get you to the same result much quicker. Linux operating systems support a wide range of these shortcuts, or hotkeys. It’s important to note that each OS can have specific hotkeys that might not work in other distributions. However, you can fix that as users can add new or modify existing combinations in their system settings. Choose your server now! In this article, we will cover universal key combinations that are universal across different desktop environments. Most of the Linux hotkeys we examine are focused on working with the terminal. The commands in this article sometimes use the Super key, which corresponds to the Windows key in Windows OS or the Cmd key in macOS. For example, the shortcut to switch keyboard layouts Super + Space in Linux is similar to Windows + Space or Cmd + Space. Basic Linux Shortcuts Let’s start with basic general-purpose shortcuts. They help perform repetitive tasks more quickly. Alt + Tab or Super + Tab: Switches between windows. Similar to the function in Windows and other OSes. Super + Space: Switches between multiple keyboard layouts. Super + A: Opens the applications menu (usually located in the bottom left corner). F2: Used to rename files. Navigate to the file, click it once, then press F2 to rename. Ctrl + Alt + T: One of the most important and popular Linux shortcuts that opens the terminal window. Alt + F2: Opens a command prompt window in the center of the screen, where you can run a command or open a program. Super + D: Minimizes all windows to show the desktop. Ctrl + Alt + Del: Brings up a prompt with “Cancel” and “Log Out” options. The system logs out automatically if no selection is made within 60 seconds. These combinations help any specialist work more efficiently in Linux. But let’s move on to the more useful terminal-related hotkeys. Linux Terminal Shortcuts The terminal in Linux is the primary tool for interacting with the command shell. Below are terminal hotkeys that will help you work more efficiently. Terminal Window Management These shortcuts help open, switch, and close terminal tabs and windows quickly: Ctrl + Shift + Q: Completely closes the terminal window. Ctrl + Shift + T: Opens a new terminal tab. Ctrl + Shift + W: Closes the current terminal tab (or window if only one tab is open). Ctrl + Shift + D: Detaches the terminal tab into a separate window. Ctrl + PgUp / PgDown: Switches between terminal tabs (previous/next). Cursor Movement in a Line Linux users primarily use the keyboard in the terminal. To avoid switching to the mouse, here are some shortcuts for faster cursor navigation: Ctrl + A (or Home): Moves the cursor to the beginning of the line. Ctrl + E (or End): Moves the cursor to the end of the line. Ctrl + XX: Quickly moves the cursor to the beginning of the line; using it again returns it to the original position. Ctrl + → / ← or Alt + F / B: The first pair moves the cursor one word forward or backward. The second pair does the same using the Alt key. Input and Editing In addition to quickly moving the cursor along the line, you can also simplify input and editing of commands.  TAB: One of the main hotkeys in the Linux terminal, used for auto-completing commands or file paths. Pressing once completes the command; pressing twice suggests multiple completion options if available. Ctrl + T: Swaps the last two characters before the cursor. Alt + T: Similar to the previous shortcut but swaps the last two words before the cursor. Alt + Backspace: Deletes the word before the cursor. Alt + D: Deletes all characters after the cursor up to the next space. Alt + U / Alt + L: The first changes all characters to the right of the cursor to uppercase; the second to lowercase. Clipboard Operations These shortcuts allow interaction with the clipboard in the terminal: copying, cutting, or pasting parts of a line or the entire line. Ctrl + W: Deletes the word before the cursor. Ctrl + U: Deletes everything from the cursor to the beginning of the line. Ctrl + K: Deletes everything from the cursor to the end of the line. Ctrl + Y: Pastes the last deleted text from the clipboard using one of the three commands above. Command History Navigation Hotkeys also help interact with the command history in the terminal. This is useful when searching for previously used commands. To view the list of executed commands, use: history To quickly find and execute a previously used command, use the shortcuts below: Ctrl + R: Opens a search prompt to find a previously used command. Press Enter to run it, or Esc to edit or exit. Ctrl + O: Executes the command found using the shortcut above. Alt + <: Loads the first command from the command history. Screen Output Management The following shortcuts control the amount of information displayed in the terminal window and help focus on specific data even during a running process. Ctrl + C: Sends the SIGINT signal to the active process, immediately interrupting it. Ctrl + D: An alternative to exit, used to close the terminal. Often used in SSH sessions to disconnect from a remote host. Ctrl + Z: Suspends the active process and sends it to the background. Use the fg command to bring it back. Use jobs to list background processes. Ctrl + L: An alternative to the clear command, clears the terminal screen. Ctrl + S / Ctrl + Q: Ctrl + S pauses the terminal output; Ctrl + Q resumes it. Useful for stopping the screen output temporarily to examine or copy information. Adding and Modifying Hotkeys A Linux user may find that some combinations do not work or are missing entirely. Hotkeys may differ depending on the distribution as each system includes a default list of predefined shortcuts. However, in most Linux environments, users can create new shortcuts or modify existing ones.  Use Super + A to open the application menu. Use the search bar to find and open Settings. In the opened window, find and go to the Devices tab. Go to the Keyboard section. On the right side, a list of default hotkeys will appear. Click on any command to open the editing window and assign a new shortcut. If the desired command is not listed, you can add a custom one by clicking the + at the bottom. Enter its name, the command to execute, and the key combination. Choose your server now! Conclusion This article reviewed the main Linux hotkeys that simplify and speed up user workflow. It’s important to note that this is not a complete list. In addition to those listed, there are other combinations that cover different functionalities in Linux distributions. And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS. Frequently Asked Questions (FAQ) What are the common shortcut keys for Linux?  While they vary by desktop environment (GNOME, KDE, etc.), standard global shortcuts include: Ctrl+Alt+T: Open a new Terminal window. Alt+Tab: Switch between open applications. Super Key (Windows Key): Open the Activities overview or Application menu. Alt+F4: Close the current window. What are the Linux shortcut keys for the terminal?  Terminal shortcuts differ from standard text editors. Key commands include: Ctrl+Shift+C / V: Copy and Paste text (standard Ctrl+C/V won't work). Ctrl+C: Interrupt (kill) the currently running process. Ctrl+L: Clear the terminal screen. Ctrl+A / Ctrl+E: Jump the cursor to the start or end of the line. How to set keyboard shortcuts in Linux?  Open your system Settings and select Keyboard. Scroll to the "Keyboard Shortcuts" section (sometimes under "View and Customize Shortcuts"). Here you can modify existing keys or add a custom shortcut by defining a command and pressing the desired key combination. How to use shortcuts on Linux?  Simply press the modifier keys (like Ctrl, Alt, or Super) and the action key simultaneously. Note that Linux shortcuts are case-sensitive regarding the Shift key; for example, Ctrl+c is different from Ctrl+Shift+C.
16 January 2026 · 7 min to read
Linux

How to Mount an SMB Share in Linux

The Server Message Block (SMB) protocol facilitates network file sharing, allowing applications to read and write to files and request services from server programs. This protocol is pivotal for seamless communication between different devices in a network, particularly in mixed OS environments like Windows and Linux. Users can access files on a Windows server or any SMB-enabled device straight from their Linux workstation by mounting an SMB share. In order to ensure seamless file sharing and network connectivity, this tutorial will walk you through the process of mounting an SMB share on Linux. Linux terminal is important tool to install SMB Share in Linux And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS. Choose your server now! Prerequisites for Mounting SMB Shares Before mounting an SMB share, ensure the following prerequisites are met: A Linux system, such as a Hostman cheap cloud server, with root or sudo privileges. The cifs-utils package installed on your Linux system. Access credentials (username and password) for the SMB share. Network connectivity between your Linux system and the SMB server. Installing Necessary Packages The cifs-utils package is essential for mounting SMB shares on Linux. Additionally, the psmisc package provides the fuser command, which helps manage and monitor file usage. Update Package List and Upgrade System First, update your package list and upgrade your system: sudo apt update Install cifs-utils and psmisc Install the necessary packages: sudo apt install cifs-utils psmisc Verify Installation Verify the installation of cifs-utils and availability of the fuser command: mount -t cifsfuser Finding SMB Share Details Get the SMB share information, such as the share name and the server name or IP address. You may need to examine the server setup or speak with your network administrator. Example: Server: smbserver.example.com Share: sharedfolder Mounting SMB Shares Using the mount Command To mount the SMB share, use the mount command with the -t cifs option, specifying the SMB protocol. Create a directory to serve as the mount point: sudo mkdir /mnt/smb_share Mount the SMB share using the following command: sudo mount -t cifs -o username=your_username,password=your_password //192.0.2.17/SharedFiles /mnt/smb_share Replace your_username and your_password with your actual username and password. Ensure /mnt/smb_share is an existing directory. Verifying the Mount To confirm that the SMB share is successfully mounted, use the mount command: mount -t cifs Navigate to the mount point and list the files: cd /mnt/smb_sharels Creating a Credentials File Make a credentials file so you don't have to enter your credentials every time. This file has to be guarded and hidden. Use a text editor to create the file: nano ~/.smbcredentials Add the following content, replacing with your actual credentials: username=your_usernamepassword=your_password Set appropriate permissions for the file: sudo chown your_username: ~/.smbcredentialssudo chmod 600 ~/.smbcredentials Mount Using the Credentials File Mount the SMB share using the credentials file: sudo mount -t cifs -o credentials=~/.smbcredentials //192.168.2.12/SharedFiles /mnt/smb_share Quick example of how SMB Shared is mounted in Linux terminal Automating SMB Share Mounts To automate the mounting process, add an entry to the /etc/fstab file. This will ensure the SMB share is mounted at boot. 1. Open /etc/fstab for editing: sudo nano /etc/fstab 2. Add the following line: //smbserver.example.com/sharedfolder /mnt/smbshare cifs username=johndoe,password=securepassword,iocharset=utf8,sec=ntlm 0 0 3. Save and close the file. 4. Test the fstab entry: sudo mount -a Ensure no errors are displayed. Troubleshooting Common Issues Permission Denied Check your credentials and permissions on the SMB server. No Such File or Directory Ensure the server IP, share path, and mount point are correct. Mount Error 13 = Permission Denied Double-check your username and password. Mount Error 112 = Host is Down Verify network connectivity and server availability. Unmounting an SMB Share To unmount the SMB share, use the umount command followed by the mount point: sudo umount /mnt/smb_share Choose your server now! Conclusion Mounting an SMB share in Linux is a straightforward process that enhances file sharing capabilities across different operating systems. By following this tutorial, you can efficiently set up and troubleshoot SMB share mounts, facilitating seamless network communication and file access. Don't forget to check how to configure server image on Lunix! Frequently Asked Questions (FAQ) How do I mount an SMB share in Linux manually?  Use the mount command with the cifs type. The syntax is: sudo mount -t cifs -o username=[user] //server/share /mnt/local_mountpoint You will be prompted to enter the password for the SMB user. How do I mount a Samba share in Linux permanently?  To mount a share automatically at boot, add an entry to your /etc/fstab file. It generally looks like this: //server/share /mnt/point cifs username=user,password=pass 0 0 Note: For security, it is better to use a credentials file instead of putting the password directly in fstab. How do I mount an SMB share in CentOS/RHEL?  First, ensure the necessary utilities are installed by running sudo dnf install cifs-utils. Once installed, the mount process is the same as other distributions: sudo mount -t cifs -o username=[user] //server/share /mnt/point What do I do if I get a "wrong fs type" error?  This usually means the helper utilities are missing. On Ubuntu/Debian, run sudo apt install cifs-utils. On CentOS/Fedora, run sudo dnf install cifs-utils. How do I unmount the share when I'm done?  Use the umount command followed by the local directory: sudo umount /mnt/local_mountpoint
14 January 2026 · 5 min to read

Do you have questions,
comments, or concerns?

Our professionals are available to assist you at any moment,
whether you need help or are just unsure of where to start.
Email us
Hostman's Support