Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App

write command in Linux with Examples

Last Updated : 03 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The `write` command in Linux facilitates the users in sending the messages directly to other logged-in users' terminals. For using this command, try on to type `write username` and then type your message. After typing your message, press `Ctrl+D` to end the session. This command is useful for quick communication between users on the same system.

In this article, we will guide you on what the write command is, how to use it, discuss effectively when to use it, and its common usage examples.

Table of Content

  • What is write command in Linux?
  • Options of Write Command
  • When to use write command in Linux?
  • Write command without any option
  • Example and Usage of write Command
  • How does Write Command Works?
  • Examples of Write Command
  • Difference between write and execute in Linux
  • Features of write command

What is write command in Linux?

The Command in Linux is used to send a message to another user. The write utility allows a user to communicate with other users, by copying lines from one user's terminal to others. When you run the write command, the user you are writing to gets a message of the form:

Message from yourname@yourhost on yourtty at hh:mm ...

Any further lines the user enter will be copied to the specified user's terminal. If the other user wants to reply, they must run write as well. When you are done, type an end-of-file or interrupt character. The other user will see the message ‘EOF’ indicating that the conversation is over.

Syntax

write user [tty]

Options of Write Command

The following are the options of write command in Linux:

OptionDescription
write usernameSends a message to the specified user's terminal.
write username ttySends a message to the specified user's terminal on a specific terminal device.
Ctrl+DEnds the message input session.
mesg yAllows messages from other users (enables write access).
mesg nDisallows messages from other users (disables write access).

When to use write command in Linux?

The following are the some of the insights on when to use the write command in linux:

  • Direct Communication: When you need to send the urgent or important messages directly to another logged-in user's terminal we use write command.
  • Privacy and Security: Write command helps in providing a secure method of communication within the same system not relying on external messaging services. It helps in senting only the visisble to the intended ensuring the confidentiality.
  • System Alerts and Notifications: It often helps the adminstrators in notifying the users about the system maintenance updates or in critical events. It ensure the users in receiving the immediate notifications on thier terminals.

Write command without any option

On using the write command without any option comes with displaying the usage of its general syntax and usage guidelines. It helps in providing the users with essential information on how to format and structure their messages when using the write command to communicate with other users on the system. This basic usage helps the users in quickly grasping on how to initiate the inter-user communication via terminal sessions, fostering the efficient collaboration and system wide messaging capabilities.

write command without any option

Example and Usage of write Command

write metal: In this command metal is the name of another user that I'm logged in with and when I execute this command with a message I get a notification on my terminal showing that I received a message from another user.

write metal
write command execution

Explanation

So the basic use case of the write command is to send messages to the users on the other terminal as a way to interact. Once you enter write command and type your message then every user that is logged in will get a pop-up message. You will also receive a message from this particular user so if any other user wants to broadcast his message he can do the same.

How does Write Command Works?

The write command in Linux facilitates that one user to send a message directly to another user's terminal session. When a user executes the write username, the system establishes a direct communication line to the specified user’s terminal. The sender can type a message, which is immediately displayed on the recipient's terminal. The session ends when the sender inputs Ctrl+D.

The following are the some of the insights on its workflow:

  • Initialization: The command is invoked by typing write username.
  • Specific Terminal: To specify a terminal, use write username tty.
  • Session End: The message session ends with Ctrl+D.
  • Permissions: The recipient can enable or disable receiving messages using mesg y or mesg n.
  • Usage Example: write john initiates a session to send a message to user "john".

Examples of Write Command

The following are the some of the examples of write command:

1. Basic Usage

  • For sending a message to a user named `john` on their current terminal, the command looks as follows:
write john
hello john, are you available for a meeting?

2. Specify Terminal

  • For a send a message to a user named suppose `alice` on a specific terminal (`tty2`). The command looks as follows:
write alice tty2
Hi Alice, please review the latest changes.

3. Interactive Messaging

  • To open an interactive session for continuously communicating with a user lets be `peter` the command looks as follows:
write -i peter

Difference between write and execute in Linux

The following are the difference between write and execute in Linux:

AspectWrite PermissionExecute Permission
FunctionAllows modifying or editing a fileAllows running a file as a program or script
File InteractionUsers can add, delete, or alter file contentUsers can execute or run the file
Directory InteractionUsers can add or remove files within the directoryUsers can access and traverse the directory
Command Examplechmod +w filename (to add write permission)chmod +x filename (to add execute permission)
SymbolRepresented by w in the permission stringRepresented by x in the permission string

Features of write command

The following are the features of write command:

  • Inter-User Communication: It facilitates with real-time messaging between the users that are logged into the same linxu system for enhancing the collaborative workflows.
  • Terminal specific messaging: It allows in targeting the message to specific user terminals by specifying the receipent's username and terminal device.
  • Simple and Direct: It provides a straightforward method for sending the short messages without the need for the additional software or complex setup.
  • Notification Capabilities: It facilitates with notifying the recipient immediately upon the message arrival with ensuring the timely notification and response within the system environment.

R

rahulkumarmandal
Improve
Article Tags :
  • Linux-Unix
  • linux-command
  • Linux-networking-commands

Similar Reads

    watch command in Linux with Examples
    The 'watch' command in Linux is a powerful utility that allows you to execute a command periodically, displaying its output in fullscreen mode. It is particularly useful for monitoring the output of commands that change over time, such as system resource usage or server status. By default, 'watch' r
    4 min read
    wc command in Linux with examples
    wc stands for word count. As the name implies, it is mainly used for counting purpose.It is used to find out number of lines, word count, byte and characters count in the files specified in the file arguments.By default it displays four-columnar output.First column shows number of lines present in a
    6 min read
    Wget Command in Linux/Unix
    Wget is the non-interactive network downloader which is used to download files from the server even when the user has not logged on to the system and it can work in the background without hindering the current process. GNU wget is a free utility for non-interactive download of files from the Web. It
    6 min read
    whatis Command in Linux with Examples
    whatis command in Linux is used to get a one-line manual page description. In Linux, each manual page has some sort of description within it. So, this command search for the manual pages names and show the manual page description of the specified filename or argument. Syntax of the `whatis` command
    5 min read
    How to Display Path of an Executable File in Linux | Which Command
    In Linux finding the exact path of an excutable file can be crucial for the system adminstration, scripting and as well for troubleshooting. The `which` command helps with providing a simple and effective way to locate the executable files within the directories that are listed in your system. In th
    6 min read
    while Command in Linux with Example
    The "while" command is a powerful tool in the Linux shell that allows you to execute a series of commands repeatedly based on a given condition. It is commonly used in shell scripts to create loops, where a block of code is executed as long as a particular condition remains true. Basic Syntax of Whi
    6 min read
    How to Display the current Username in Linux | whoami Command
    Imagine you're working on your computer and forget who you're logged in as. In Linux, there's a special trick called "whoami" that's like asking "Hey computer, who am I right now?" This article explains how this simple command works and helps you remember who's in charge! Don't worry, it won't be fu
    4 min read
    write command in Linux with Examples
    The `write` command in Linux facilitates the users in sending the messages directly to other logged-in users' terminals. For using this command, try on to type `write username` and then type your message. After typing your message, press `Ctrl+D` to end the session. This command is useful for quick
    6 min read
    xargs command in Linux with examples
    xargs is a Unix command which can be used to build and execute commands from standard input. Importance:Some commands like grep can accept input as parameters, but some commands accept arguments, this is a place where xargs came into the picture. Syntax of `xargs` command in Linuxxargs [options] [co
    5 min read
    xdg-open command in Linux with Examples
    xdg-open command in the Linux system is used to open a file or URL in the user’s preferred application. The URL will be opened in the user’s preferred web browser if a URL is provided. The file will be opened in the preferred application for files of that type if a file is provided. xdg-open support
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences