Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Operating System Articles
Page 62 of 171
Delete the History of the Last n Commands on Linux
In Linux, the command history is a record of previously executed commands stored in a file called .bash_history, located in each user's home directory. The history command displays this history, and commands are assigned sequential numbers that can be executed using !number syntax. For example, typing !123 will execute the command numbered 123 in the history. There are several options to customize command history behavior: The history -c command clears the current session's command history. The HISTFILE environment variable specifies a different file to store command history. The HISTSIZE and HISTFILESIZE variables control the maximum number of ...
Read MoreMonitoring Network Usage in Linux
Network monitoring in Linux involves tracking and analyzing network traffic, bandwidth usage, and connection statistics to ensure optimal system performance. Unlike general system monitoring that focuses on CPU and memory, network monitoring specifically targets data flow across network interfaces and helps identify bottlenecks, suspicious activity, and resource-hungry applications. Network Monitoring Tools Linux provides several powerful command-line tools for network monitoring, each serving different purposes − nload − Displays real-time network traffic statistics with visual graphs for interface monitoring. Speedometer − Shows network usage with customizable display formats and measurement units. iftop − Lists active network connections ...
Read MoreSpecify an Editor for Crontab on Linux
The default editor for crontab on Linux is the vi editor. However, this can be changed by setting the VISUAL or EDITOR environment variable to the desired editor before running the crontab command. For example, to use nano as the editor for crontab, the command would be − export VISUAL=nano; crontab -e or export EDITOR=nano; crontab -e This will open the crontab file in nano for editing. Methods to Change Crontab Editor Temporary Change To temporarily change the editor for a single crontab session, set the environment variable inline ...
Read MoreStoring a Command in a Variable in a Shell Script
In shell scripting, you can store a command in a variable to improve code organization and reusability. This technique allows you to define commands once and execute them multiple times throughout your script. Basic Command Storage The basic syntax for storing a command in a variable is − variable_name="command" For example − current_date="date" list_files="ls -la" To execute the stored command, you need to use command substitution or eval − # Using eval (less secure) eval $current_date # Using command substitution (preferred) $($current_date) Storing Commands in ...
Read MoreRunning Script or Command as Another User in Linux
There are several ways to run a script or command as another user in Linux. The most common methods are using the su command (switch user), the sudo command (superuser do), and the runuser command. Each approach has different use cases, security implications, and requirements. These commands are essential for system administration tasks where you need to execute operations with different user privileges without logging out and back in as another user. Using su Command The su command allows you to switch to another user's account. The basic syntax is: su [options] [username] ...
Read MoreRunning Multi-Line Shell Code at Once From Single Prompt
Running multi-line shell code at once allows you to execute complex commands and scripts efficiently without typing each line individually. There are several techniques to accomplish this, from creating shell scripts to using command-line operators and here-documents. Shell Script Method The most common approach is creating a shell script file. Use any text editor to write your code and save it with a .sh extension: #!/bin/bash echo "Hello, World!" echo "This is a shell script." Execute the script using: bash script.sh Here-Document (EOF) Method The here-document technique uses the
Read MoreRemove Lines Which Appear in File B From Another File A in Linux
Removing lines from one file that appear in another file is a common task in Linux system administration and data processing. This operation, also known as set difference, can be accomplished using several command-line utilities, each with its own advantages and use cases. Using the grep Command The grep command is the most straightforward approach for this task. It uses pattern matching to filter lines. grep -v -f fileB.txt fileA.txt > outputFile.txt This command uses the -v option to invert the match (show non-matching lines) and -f to specify the file containing patterns to ...
Read MoreVolatile Storage vs Non-Volatile Storage
Volatile and Non-Volatile storage are the two fundamental forms of storage in any computer system. Understanding their differences is crucial for system design and data management. Volatile Storage This is a type of computer memory that retains data only while there is power and the data is lost when power is switched off. A prime example of volatile memory is RAM. It is a type of primary storage that allows the user to randomly access any part of the data regardless of its position in roughly the same time. This is not possible using other storage devices such ...
Read MoreSingle Processor Systems
A single processor system contains only one CPU that executes one process at a time. The processor selects processes from the ready queue and handles them sequentially. Most general-purpose computers use single processor systems as they are cost-effective and sufficient for everyday computing tasks. In a single processor system, even though multiple applications may be running simultaneously, only one process can actually execute at any given moment. The operating system uses time-sharing to create the illusion of parallel execution by rapidly switching between processes. Architecture of Single Processor Systems Single Processor System Architecture ...
Read MorePeer to Peer Computing
Peer-to-Peer (P2P) Computing is a distributed network architecture where nodes (computers) act as equal participants, serving both as clients and servers. Unlike traditional client-server models, each node can request services and provide resources simultaneously, creating a decentralized system where all participants share the workload equally. Peer-to-Peer Network Architecture ...
Read More