A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/essential-linuxunix-commands/ below:

Essential Unix Commands - GeeksforGeeks

Essential Unix Commands

Last Updated : 04 Apr, 2024

Unix commands are a set of commands that are used to interact with the Unix operating system. Unix is a powerful, multi-user, multi-tasking operating system that was developed in the 1960s by Bell Labs. Unix commands are entered at the command prompt in a terminal window, and they allow users to perform a wide variety of tasks, such as managing files and directories, running processes, managing user accounts, and configuring network settings. Unix is now one of the most commonly used Operating systems used for various purposes such as Personal use, Servers, Smartphones, and many more. It was developed in the 1970's at AT& T Labs by two famous personalities Dennis M. Ritchie and Ken Thompson. 

Basic Unix commands:  File System Navigation Unix Command

Command

Description

Example

cd

Changes the current working directory.

cd Documents

ls

Lists files and directories in the current directory.

ls

pwd

Prints the current working directory.

pwd

mkdir

Creates a new directory.

mkdir new_folder

rmdir

Removes an empty directory.

rmdir empty_folder

mv

Moves files or directories.

mv file1.txt Documents/

File Manipulation Unix Command

Command

Description

Example

touch

Creates an empty file or updates the access and modification times.

touch new_file.txt

cp

Copies files or directories.

cp file1.txt file2.txt

mv

Moves files or directories.

mv file1.txt Documents

rm

Remove files or directories.

rm old_file.txt

chmod

Changes the permissions of a file or directory.

chmod 644 file.txt

chown

Changes the owner and group of a file or directory.

chown user:group file.txt

ln

Creates links between files.

ln -s target_file symlink

cat Concatenates files and displays their contents. cat file1.txt file2.txt head Displays the first few lines of a file. head file.txt tail Displays the last few lines of a file. tail file.txt more Displays the contents of a file page by page. more file.txt less Displays the contents of a file with advanced navigation features. less file.txt diff Compares files line by line. diff file1.txt file2.txt patch Applies a diff file to update a target file. patch file.txt < changes.diff Process Management Unix Command

Command

Description

Example

ps Displays information about active processes, including their status and IDs. ps aux top Displays a dynamic real-time view of system processes and their resource usage. top kill Terminates processes using their process IDs (PIDs). kill <pid> pkill Sends signals to processes based on name or other attributes. pkill -9 firefox killall Terminates processes by name. killall -9 firefox renice Changes the priority of running processes. renice -n 10 <pid> nice Runs a command with modified scheduling priority. nice -n 10 command pstree Displays running processes as a tree. pstree pgrep Searches for processes by name or other attributes. pgrep firefox jobs Lists active jobs and their status in the current shell session. jobs bg Puts a job in the background. bg <job_id> fg Brings a background job to the foreground. fg <job_id> nohup Runs a command immune to hangups, with output to a specified file. nohup command & disown Removes jobs from the shell's job table, allowing them to run independently. disown <job_id> Text Processing Unix Command

Command

Description

Example

grep Searches for patterns in text files. grep "error" logfile.txt sed Processes and transforms text streams. sed 's/old_string/new_string/g' file.txt awk Processes and analyzes text files using a pattern scanning and processing language. awk '{print $1, $3}' data.csv Network Communication Unix Command Command Description Example ping Tests connectivity with another host using ICMP echo requests. ping google.com traceroute Traces the route that packets take to reach a destination. traceroute google.com nslookup Queries DNS servers for domain name resolution and IP address information. nslookup google.com dig Performs DNS queries, providing detailed information about DNS records. dig google.com host Performs DNS lookups, displaying domain name to IP address resolution. host google.com whois Retrieves information about domain registration and ownership. whois google.com ssh Provides secure remote access to a system. ssh username@hostname scp Securely copies files between hosts over a network. scp file.txt username@hostname:/path/ ftp Transfers files between hosts using the File Transfer Protocol (FTP). ftp hostname telnet Establishes interactive text-based communication with a remote host. telnet hostname netstat Displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. netstat -tuln ifconfig Displays or configures network interfaces and their settings. ifconfig iwconfig Configures wireless network interfaces. iwconfig wlan0 route Displays or modifies the IP routing table. route -n arp Displays or modifies the Address Resolution Protocol (ARP) cache. arp -a ss Displays socket statistics. ss -tuln hostname Displays or sets the system's hostname. hostname mtr Combines the functionality of ping and traceroute, providing detailed network diagnostic information. mtr google.com System Administration Unix Command

Command

Description

Example

df

Displays disk space usage.

df -h

du

Displays disk usage of files and directories.

du -sh /path/to/directory

crontab -e

Manages cron jobs, which are scheduled tasks that run at predefined times or intervals.

crontab -e

Text Editors in Unix Text Editor Description Example Vi / Vim Vi (Vim) is a highly configurable, powerful, and feature-rich text editor based on the original Vi editor. Vim offers modes for both command-line operations and text editing. Open a file with Vim: vim filename
Exit Vim editor: Press Esc, then type :wq and press Enter Emacs Emacs is a versatile text editor with extensive customization capabilities and support for various programming languages. Open a file with Emacs: emacs filename
Save and exit Emacs: Press Ctrl + X, then Ctrl + S and Ctrl + X, then Ctrl + C to exit Nano Nano is a simple and user-friendly text editor designed for ease of use and accessibility. Open a file with Nano: nano filename
Save and exit Nano: Press Ctrl + O, then Ctrl + X Ed Ed is a standard Unix text editor that operates in line-oriented mode, making it suitable for batch processing and automation tasks. Open a file with Ed: ed filename
Exit Ed editor: Type q and press Enter Jed Jed is a lightweight yet powerful text editor that provides an intuitive interface and support for various programming languages. Open a file with Jed: jed filename
Save and exit Jed: Press Alt + X, then type exit and press Enter Conclusion

In conclusion, Unix commands serve as a fundamental toolkit for navigating and managing the Unix operating system, which has evolved from its inception in the 1960s to become one of the most widely used OS platforms across various domains including personal computing, servers, and mobile devices. From its origins at Bell Labs with developers Dennis M. Ritchie and Ken Thompson to the birth of the C programming language and the subsequent emergence of Unix-like systems such as Linux, the Unix ecosystem has significantly shaped the computing landscape. Understanding basic Unix commands is essential for users to efficiently manipulate files, manage processes, configure networks, and perform system administration tasks, thereby empowering them to leverage the full potential of Unix-based systems for diverse computing needs.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4