You are reading the article Basics Linux/Unix Commands With Examples & Syntax (List) updated in December 2023 on the website Daihoichemgio.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 Basics Linux/Unix Commands With Examples & Syntax (List)
File Management becomes easy if you know the right basic command in Linux.
Sometimes, commands are also referred as “programs” since whenever you run a command, it’s the corresponding program code, written for the command, which is being executed.
Let’s learn the must know Linux basic commands with examples:
Listing files (ls)
If you want to see the list of files on your UNIX or Linux system, use the ‘ls’ command.
It shows the files /directories in your current directory.
Note:
Directories are denoted in blue color.
Files are denoted in white.
You will find similar color schemes in different flavors of Linux.
Suppose, your “Music” folder has following sub-directories and files.
You can use ‘ls -R’ to shows all the files not only in directories but also subdirectories
NOTE: These Linux basics commands are case-sensitive. If you enter, “ls – r” you will get an error.
‘ls -al’ gives detailed information of the files. The command provides information in a columnar format. The columns contain the following information:
1st Column
File type and access permissions
2nd Column
# of HardLinks to the File
3rd Column
Owner and the creator of the file
4th Column
Group of the owner
5th Column
File size in Bytes
6th Column
Date and Time
7th Column
Directory or File name
Let’s see an example –
Listing Hidden FilesHidden items in UNIX/Linux begin with –
at the start, of the file or directory.
at the start, of the file or directory.
Any Directory/file starting with a ‘.’ will not be seen unless you request for it. To view hidden files, use the command.
ls -a Creating & Viewing FilesThe ‘cat’ server command is used to display text files. It can also be used for copying, combining and creating new text files. Let’s see how it works.
To create a new file, use the command
Add content
Press ‘ctrl + d’ to return to command prompt.
How to create and view files in Linux/Unix
To view a file, use the command –
cat filenameLet’s see the file we just created –
Let’s see another file sample2
The syntax to combine 2 files is –
Let’s combine sample 1 and sample 2.
As soon as you insert this command and hit enter, the files are concatenated, but you do not see a result. This is because Bash Shell (Terminal) is silent type. Shell Commands will never give you a confirmation message like “OK” or “Command Successfully Executed”. It will only show a message when something goes wrong or when an error has occurred.
To view the new combo file “sample” use the command
cat sampleNote: Only text files can be displayed and combined using this command.
Deleting FilesThe ‘rm’ command removes files from the system without confirmation.
To remove a file use syntax –
rm filenameHow to delete files using Linux/Unix Commands
Moving and Re-naming filesTo move a file, use the command.
mv filename new_file_locationSuppose we want to move the file “sample2” to location /home/guru99/Documents. Executing the command
mv sample2 /home/guru99/Documents
mv command needs super user permission. Currently, we are executing the command as a standard user. Hence we get the above error. To overcome the error use command.
sudo command_you_want_to_executeSudo program allows regular users to run programs with the security privileges of the superuser or root.
Sudo command will ask for password authentication. Though, you do not need to know the root password. You can supply your own password. After authentication, the system will invoke the requested command.
Sudo maintains a log of each command run. System administrators can trackback the person responsible for undesirable changes in the system.
guru99@VirtualBox:~$ sudo mv sample2 /home/quru99/Documents [sudo] password for guru99: **** guru99@VirtualBox:~$For renaming file:
mv filename newfilenameNOTE: By default, the password you entered for sudo is retained for 15 minutes per terminal. This eliminates the need of entering the password time and again.
You only need root/sudo privileges, only if the command involves files or directories not owned by the user or group running the commands
Directory ManipulationsDirectory Manipulation in Linux/Unix
Enough with File manipulations! Let’s learn some directory manipulation Linux commands with examples and syntax.
Creating Directories
Directories can be created on a Linux operating system using the following command
mkdir directorynameThis command will create a subdirectory in your present working directory, which is usually your “Home Directory”.
For example,
mkdir mydirectoryIf you want to create a directory in a different location other than ‘Home directory’, you could use the following command –
mkdirFor example:
mkdir /tmp/MUSICwill create a directory ‘Music’ under ‘/tmp’ directory
You can also create more than one directory at a time.
Removing DirectoriesTo remove a directory, use the command –
rmdir directorynameExample
rmdir mydirectorywill delete the directory mydirectory
Tip: Ensure that there is no file / sub-directory under the directory that you want to delete. Delete the files/sub-directory first before deleting the parent directory.
Renaming DirectoryThe ‘mv’ (move) command (covered earlier) can also be used for renaming directories. Use the below-given format:
mv directoryname newdirectorynameLet us try it:
How to rename a directory using Linux/Unix Commands
Other Important Commands The ‘Man’ commandMan stands for manual which is a reference book of a Linux operating system. It is similar to HELP file found in popular software.
To get help on any command that you do not understand, you can type
manThe terminal would open the manual page for that command.
For an example, if we type man man and hit enter; terminal would give us information on man command
The History CommandHistory command shows all the basic commands in Linux that you have used in the past for the current terminal session. This can help you refer to the old commands you have entered and re-used them in your operations again.
The clear commandThis command clears all the clutter on the terminal and gives you a clean window to work on, just like when you launch the terminal.
Pasting commands into the terminalMany times you would have to type in long commands on the Terminal. Well, it can be annoying at times, and if you want to avoid such a situation then copy, pasting the commands can come to rescue.
Printing in Unix/LinuxHow to print a file using Linux/Unix commands
Let’s try out some Linux basic commands with examples that can print files in a format you want. What more, your original file does not get affected at all by the formatting that you do. Let us learn about these commands and their use.
‘pr’ command
This command helps in formatting the file for printing on the terminal. There are many Linux terminal commands available with this command which help in making desired format changes on file. The most used ‘pr’ Unix commands with examples are listed below.
Option Function
-x
Divides the data into ‘x’ columns
-h “header”
Assigns “header” value as the report header
-t
Does not print the header and top/bottom margins
-d
Double spaces the output file
-n
Denotes all line with numbers
-l page length
Defines the lines (page length) in a page. Default is 56
-o margin
Formats the page by the margin number
Let us try some of the options and study their effects.
Dividing data into columns‘Tools’ is a file (shown below).
We want its content to be arranged in three columns. The syntax for the same would be:
pr -x FilenameThe ‘-x’ option with the ‘pr’ command divides the data into x columns.
Assigning a headerThe syntax is:
pr -h "Header" FilenameThe ‘-h’ options assigns “header” value as the report header.
As shown above, we have arranged the file in 3 columns and assigned a header
Denoting all lines with numbersThe syntax is:
pr -n FilenameThis command denotes all the lines in the file with numbers.
These are some of the ‘pr’ command options that you can use to modify the file format.
Printing a fileOnce you are done with the formatting, and it is time for you to get a hard copy of the file, you need to use the following command:
lp Filenameor
lpr FilenameIn case you want to print multiple copies of the file, you can use the number modifier.
In case you have multiple printers configured, you can specify a particular printer using the Printer modifier
Installing SoftwareIn windows, the installation of a program is done by running the chúng tôi file. The installation bundle contains the program as well various dependent components required to run the program correctly.
Using Linux/Unix basic commands, installation files in Linux are distributed as packages. But the package contains only the program itself. Any dependent components will have to be installed separately which are usually available as packages themselves.
You can use the apt commands to install or remove a package. Let’s update all the installed packages in our system using command –
sudo apt-get updateThe easy and popular way to install programs on Ubuntu is by using the Software center as most of the software packages are available on it and it is far more secure than the files downloaded from the internet.
Also Check:- Linux Command Cheat Sheet
Linux Mail CommandFor sending mails through a terminal, you will need to install packages ‘mailutils’.
The command syntax is –
sudo apt-get install packagenameOnce done, you can then use the following syntax for sending an email.
mail -s 'subject' -c 'cc-address' -b 'bcc-address' 'to-address'This will look like:
Press Cntrl+D you are finished writing the mail. The mail will be sent to the mentioned address.
Summary:
You can format and print a file directly from the terminal. The formatting you do on the files does not affect the file contents
In Unix/Linux, software is installed in the form of packages. A package contains the program itself. Any dependent component needs to be downloaded separately.
You can also send e-mails from terminal using the ‘mail’ network commands. It is very useful Linux command.
Linux Command ListBelow is a Cheat Sheet of Linux/ Unix basic commands with examples that we have learned in this Linux commands tutorial
Command Description
ls Lists all files and directories in the present working directory
ls – R
Lists files in sub-directories as well
ls – a
Lists hidden files as well
ls – al
Lists files and directories with detailed information like permissions, size, owner, etc.
Creates a new file
cat filename
Displays the file content
Joins two files (file1, file2) and stores the output in a new file (file3)
mv file “new file path”
Moves the files to the new location
mv filename new_file_name
Renames the file to a new filename
sudo
Allows regular users to run programs with the security privileges of the superuser or root
rm filename
Deletes a file
man
Gives help information on a command
history
Gives a list of all past basic Linux commands list typed in the current terminal session
clear
Clears the terminal
mkdir directoryname
Creates a new directory in the present working directory or a at the specified path
rmdir
Deletes a directory
mv
Renames a directory
pr -x
Divides the file into x columns
pr -h
Assigns a header to the file
pr -n
Denotes the file with Line Numbers
lpr c
Prints “c” copies of the File
lp -d
lpr -P
Specifies name of the printer
apt-get
Command used to install and update packages
mail -s ‘subject’ -c ‘cc-address’ -b ‘bcc-address’ ‘to-address’
Command to send email
mail -s “Subject” to-address < Filename
Command to send email with attachment
Download Linux Tutorial PDF
You're reading Basics Linux/Unix Commands With Examples & Syntax (List)
Explaination On Mariadb Commands With Examples
Definition of MariaDB Commands
Initially, MariaDB was split from the MySQL database management system, industrialized by its innovative developers. This tool of DBMS delivers data processing abilities for both enterprise and small type tasks.
We can say that MariaDB is an enhanced version of MySQL server which comes with several inbuilt powerful features and many stabilities, performance progresses, and safety that a user cannot get in MySQL.
In MariaDB, you can find more memory storage engine for MariaDB commands as compared to MySQL. We can associate with the MariaDB server with the help of the MySQL program, i.e. command-line having the appropriate username, password, hostname, and name of the database.
MariaDB commands are the administrative commands that are significant commands which a user will implement on a regular basis when functioning with MariaDB.
MariaDB commands..explain each with an example.
Start Your Free Software Development Course
Web development, programming languages, Software testing & others
Along with supporting PHP, a well-liked web development language, MariaDB offers technology of the type seen in Galera Clusters. In addition, MariaDB commands can perform on several operating systems and support many programming languages.
Let us discuss some of the administrative commands in MariaDB mentioned as follows:
USE [name of the database] – Arranges the current default database.
SHOW DATABASES – Provides a list of databases that are present currently on the server.
SHOW TABLES – Provides a list of all non-temporary tables from the database server.
SHOW COLUMNS FROM [Name of the table] – Delivers the column information concerning the stated table.
SHOW INDEX FROM TABLENAME [Name of the table] – Delivers information about the table index associated with the definite table.
SHOW TABLE STATUS LIKE [Name of table] – Provides database tables with information of non-temporary tables and the pattern appearing after using the clause LIKE that is applied to fetch the table names.
MariaDB CommandsNow, let us discuss and illustrate the commands in detail as follows:
1. Creating Database as well as TablesWe will use the following syntax for this:
CREATE DATABASE Nameofdatabase;We can execute as:
CREATE DATABASE Books;Output:
2. To select a DatabaseIf any user wants to use or perform on a definite database, you need to select it from the database lists available on MariaDB. After this, we can proceed to create tasks like creating tables in that particular database selected. The command is as follows:
Syntax:
USE Nameofdatabase;Command
USE Books;Output:
3. To create a database tableAfter we have selected the specified database, we can create a table within it by using the following syntax:
CREATE TABLE name_of_table (Name_of_Column, Column_data_type);From the columns created, one of the columns needs to be a primary key which will not permit NULL values to be inserted. For example,
CREATE TABLE EngBooks(EngID INT PRIMARY KEY NOT NULL AUTO_INCREMENT, BookName VARCHAR(255) NOT NULL, BookPrice INT NOT NULL);Output:
4. To show database tablesWhen you have created the tables in the database, you can view the tables, whether created effectively or not, to confirm. The following MariaDB command will display the list of tables present in the database:
SHOW TABLES;Output:
5. To show the table structureIf a user requires to view the structure of any stated table in MariaDB, we will use the DESCRIBE command with syntax as follows:
DESC Name_of_Table; For instance, DESC EngBooks;Output:
6. CRUD commands and some clause commands
INSERT: We need to apply the insert command to enter any data value into the table in MariaDB having the below syntax:
INSERT INTO Name_of_Table(Column1, Column2,….ColumnN) VALUES(Value1,…ValueN),(Value1,…,ValueN),……;Let us show by implementation into the create table above:
INSERT INTO EngBooks(EngID, BookName, BookPrice) VALUES(101, 'Networking', 5000); select * from EngBooks;Output:
Also, we can enter multiple record rows by using the syntax as follows:
INSERT INTO EngBooks(EngID, BookName, BookPrice) VALUES(101, 'Networking', 5000), (102, 'Computer', 4000), (103, 'Maths', 3500); select * from EngBooks;Output:
We must use quotes, either single or double, for string values while executing the Insert statements in the server.
SELECT: We can view the contents or data records of the database table using the MariaDB command SELECT with the syntax:
SELECT * FROM Name_of_table;Here, * denotes all means all rows and columns as data will be fetched when the command executes like this:
SELECT * FROM EngBooks;Output:
UPDATE: If any user or admin wants to change or alter any record data within the database table that is already inserted into it, then we have to implement the update command as follows:
UPDATE Name_of_Table SET fieldname1 = ValueX, fieldname2 = ValueY,…;For instance,
UPDATE EngBooks SET BookPrice = 7000 WHERE EngID = 101;Output:
DELETE: We use the delete command to remove one or more rows from the table records in the database with syntax as:
DELETE FROM Name_of_Table [WHERE clause conditions] [ORDER BY Expr {ASC/DESC}] [LIMIT Rows_number]; DELETE FROM EngBooks WHERE EngID = 103;Output:
WHERE: This clause is useful to state the definite location where a user wants to make the alteration and applied together with SELECT, INSERT, DELETE, and UPDATE like queries with the syntax:
SELECT * FROM EngBooks WHERE BookPrice < 5000;Output:
LIKE: This clause is used to define certain data pattern and fetch the related matching items from the database table like below:
SELECT BookName, BookPrice FROM EngBooks WHERE BookName LIKE ‘N%’;Output:
ORDER BY: This clause provides the data accessible in the sorted form in either ascending or descending order with SELECT statement as:
SELECT * FROM EngBooks WHERE BookPrice < 5000 ORDER BY BookPrice DESC;Output:
DISTINCT: This clause will help to remove the duplicate data records while fetching certain data values from the database table to receive unique ones:
SELECT DISTINCT BookPrice FROM EngBooks;Output:
FROM: This clause is applied to retrieve records from a specific database table as follows:
SELECT * FROM EngBooks;Output:
Conclusion
MariaDB server operates under the licenses such as LGPL, BSD, or GPL. MariaDB commands are based on a standard and famous querying language, i.e., SQL. It has many storage engines with high-performance functioning.
MariaDB approaches with many additional commands which are not accessible in MySQL. Since MySQL contains some features that cause a negative influence on the DBMS performance so these things have been substituted in MariaDB.
Recommended ArticlesWe hope that this EDUCBA information on “MariaDB Commands” was beneficial to you. You can view EDUCBA’s recommended articles for more information.
Nfts Basics: Examples, Uses, And Benefits
What are NFTs?
NFTs (Non-Fungible Tokens) are a type of cryptographic asset that represent unique units of value. They are unlike other tokens such as Bitcoin and Ethereum which are fungible, meaning that each unit is interchangeable with another. This makes them perfect for representing digital assets like collectibles, game items, or real estate. Nowadays there are many online platforms that are helping their users to gain
nft profit
.
NFTs can be stored on blockchain platforms like Ethereum and used to transfer ownership between users. They can also be used to represent rights and permissions within decentralized applications. For example, an NFT might be used to represent the voting power of a user in a Decentralized Autonomous Organization (DAO).
How do NFTs work?NFTs are created by issuing a unique cryptographic key to represent the asset. This key is used to control the ownership of the NFT and can be transferred between users. The NFTs are stored on a blockchain platform where they are tracked and verified by the network.
What are some examples of NFTs?Some examples of NFTs include digital collectibles like CryptoKitties, game items like swords and armor in games like Blockchain Cuties, and real estate like property on the Ethereum blockchain.
How can I use NFTs?There are many ways to use NFTs. Some common applications include:
-Transferring ownership of digital assets between users.
-Representing rights and permissions within decentralized applications.
-Tracking the provenance of
digital assets
.
-Creating digital collectibles.
-Building online marketplaces for NFTs.
What are the benefits of NFTs?The benefits of NFTs include:
-Security: NFTs are stored on a blockchain platform where they are tracked and verified by the network. This makes them secure and difficult to forge.
-Transparency: The ownership of an NFT is transparent and can be verified by anyone on the blockchain.
-Fungibility: Unlike other tokens such as Bitcoin and Ethereum, NFTs are not fungible meaning that each unit is unique. This makes them perfect for representing digital assets like collectibles, game items, or real estate.
-Portability: NFTs can be transferred between users easily and quickly. This makes them ideal for use in digital applications.
-Decentralization: NFTs are decentralized and not controlled by any central authority. This makes them secure.
How to Invest in NFTs?When it comes to investing in NFTs, there are a few things that you need to take into account. Firstly, you need to decide what kind of NFTs you want to invest in. There is a range of different options available, from digital collectibles to tokens that represent real-world assets.
Once you’ve decided on the type of NFTs you want to invest in, you need to think about how you’re going to store them. Each type of NFT has its own storage requirements, so make sure you research this before investing.
Finally, you need to think about how you’re going to trade your NFTs. There are a number of different platforms available, so you need to find one that suits your needs.
With these things in mind, investing in NFTs can be a great way to diversify your portfolio and increase your chances of generating returns. So, if you’re thinking about investing in NFTs, make sure you follow these tips!
Risks Involved in NFTs InvestmentIt is important for investors to be aware of the risks involved in investing in NFTs. One of the main risks is that the value of NFTs can be impacted by a variety of factors, including regulatory changes, technology changes, or simply because the market for NFTs grows or shrinks.
Additionally, there is always a risk that an investor could lose their entire investment if the holder of an NFT decides to sell it. This could occur if the holder is not able to find a buyer at a price they are willing to accept, or if the holder becomes subject to a
cyberattack
that results in the theft of their tokens.
Finally, investors should be aware that there is also risk associated with holding and trading NFTs on exchanges, as these exchanges may be hacked or experience other technical issues that could result in the loss of funds. As with any type of investment, it is important for investors to do their own research and understand the risks before deciding to invest in NFTs.
ConclusionThere are a number of risks involved in investing in NFTs, including the risk that the value of NFTs could be impacted by a variety of factors, the risk that an investor could lose their entire investment, and the risk associated with holding and trading NFTs on exchanges. Investors should do their own research to understand these risks before deciding to invest in NFTs.
25 Useful Linux Commands For System Administrators
Linux is a popular open-source operating system used by many system administrators for managing their servers and infrastructure. As a system administrator, it is essential to have a good understanding of Linux commands to manage and troubleshoot system efficiently. In this article, we will discuss 25 useful Linux commands for system administrators, along with their examples.
ls – List Directory ContentsThe ls command is used to list contents of a directory. By default, it lists files and directories in current directory.
Example − To list all files and directories in current directory, use following command −
ls cd – Change DirectoryThe cd command is used to change current working directory.
Example − To change current directory to /usr/local/bin, use following command −
cd /usr/local/bin pwd – Print Working DirectoryThe pwd command is used to print current working directory.
Example − To print current working directory, use following command −
pwd mkdir – Make DirectoryThe mkdir command is used to create a new directory.
Example − To create a new directory called test, use following command −
mkdir test rm – Remove Files or DirectoriesThe rm command is used to remove files or directories.
Example − To remove a file called chúng tôi use following command −
rm myfile.txt rmdir – Remove DirectoriesThe rmdir command is used to remove directories.
Example − To remove a directory called test, use following command −
rmdir test cp – Copy Files or DirectoriesThe cp command is used to copy files or directories.
Example − To copy a file called chúng tôi to a new location /tmp, use following command −
cp chúng tôi /tmp mv – Move or Rename Files or DirectoriesThe mv command is used to move or rename files or directories.
Example − To rename a file called chúng tôi to chúng tôi use following command −
mv chúng tôi newfile.txt cat – Display File ContentsThe cat command is used to display contents of a file.
Example − To display contents of a file called chúng tôi use following command −
cat myfile.txt tail – Display Last Part of a FileThe tail command is used to display last part of a file.
Example − To display last 10 lines of a file called chúng tôi use following command −
tail -n 10 myfile.txt head – Display First Part of a FileThe head command is used to display first part of a file.
Example − To display first 10 lines of a file called chúng tôi use following command −
head -n 10 myfile.txt less – Display File Contents Page by PageThe less command is used to display file contents page by page.
Example − To display contents of a file called chúng tôi page by page, use following command −
less myfile.txt top – Display System Resource UsageThe top command is used to display system resource usage, such as CPU and memory usage.
Example − To display system resource usage, use following command −
top ps – Display Running ProcessesThe ps command is used to display running processes.
Example − To display running processes, use following command −
ps aux kill – Terminate ProcessesThe kill command is used to terminate processes.
Example − To terminate a process with a process ID of 1234, use following command −
kill 1234 df – Display Disk Space UsageThe df command is used to display disk space usage.
Example − To display disk space usage for all mounted file systems, use following command −
df -h du – Display Directory Space UsageThe du command is used to display directory space usage.
Example − To display directory space usage for current directory, use following command −
du -sh . ifconfig – Configure Network InterfacesThe ifconfig command is used to configure network interfaces.
Example − To display network interface information, use following command −
ifconfig ping – Test Network ConnectivityThe ping command is used to test network connectivity.
Example − To test network connectivity to a host with IP address 192.168.1.1, use following command −
ping 192.168.1.1 netstat – Display Network ConnectionsThe netstat command is used to display network connections.
Example − To display active network connections, use following command −
netstat -an ssh – Securely Connect to a Remote SystemThe ssh command is used to securely connect to a remote system.
Example − To connect to a remote system with IP address 192.168.1.1, use following command −
ssh 192.168.1.1 scp – Securely Copy Files Between SystemsThe scp command is used to securely copy files between systems.
Example − To copy a file called chúng tôi from local system to a remote system with IP address 192.168.1.1, use following command −
scp chúng tôi [email protected]:/path/to/destination wget – Download Files From WebThe wget command is used to download files from web.
Example − To download a file from a website, use following command −
tar – Create and Extract Compressed ArchivesThe tar command is used to create and extract compressed archives.
Example − To create a compressed archive of a directory called mydir, use following command −
tar -czvf chúng tôi mydir crontab – Schedule Tasks to Run at Specific TimesThe crontab command is used to schedule tasks to run at specific times.
Example − To schedule a task to run every day at 2am, use following command −
0 2 * * * /path/to/command useradd – Add a New User to SystemThe useradd command is used to add a new user to system.
Example − To add a new user with username “john”, use following command −
useradd john passwd – Change User PasswordThe passwd command is used to change password of a user.
Example − To change password for user “john”, use following command −
passwd john sudo – Execute a Command with Superuser PrivilegesThe sudo command is used to execute a command with superuser privileges.
Example − To execute a command as a superuser, use following command −
sudo command ConclusionIn conclusion, Linux commands are essential for system administrators to manage and troubleshoot their systems efficiently. above 25 commands are just a few of many commands available in Linux. By mastering these commands, you can become more proficient in managing Linux systems. I hope this article has been useful in providing you with some useful Linux commands to help you in your role as a system administrator.
5 Deadly Linux Commands You Should Never Run
As a Linux user, you probably have searched online for articles and tutorials that show you how to use the terminal to run some commands. While most of these commands are harmless and could help you become more productive, there are some commands that are deadly and could wipe out your whole machine. In this article, let’s check out some of the deadly Linux commands that you should never run.
Note: These commands are really harmful, so please don’t try to reproduce them on your Linux machines. You have been warned.
1. Deletes Everything Recursivelyrm
-rf
/
This is one of the most deadly Linux commands around. The functionality of this command is really simple. It forcefully removes or deletes (rm) all the files and folders recursively (-rf) in the root directory (/) of your Linux machine. Once you delete all the files in the root directory, there is no way that you can boot into your Linux system again. Also be aware that the below command comes in many other forms such as rm -rf * or rm -rf. So always be careful when ever you are executing a command that includes rm.
2. Fork Bomb 3. Move Everything to Nothingnessmv
~/
dev/
nullThe functionality of this command is really basic and simple. All it does is move (mv) the contents of your home folder (~) into the /dev/null folder. This looks really innocent, but the catch is that there is no folder called “Null,” and it simply means that you are moving all your files and folders into nothingness essentially destroying all the files irrecoverably.
4. Format Hard Drive mkfs.ext3/
dev/
sdaThis command is really a disaster as it formats your entire hard drive and replaces it with the new ext3 file system. Once you execute the command, all your data is lost irrecoverably. So never ever try this command or any other suspicious command that involves your hard drive (sda).
5. Output Command Directly to Hard Drive ConclusionUsing the command line is pretty interesting but don’t blindly execute all the commands you find in the internet. A single command is enough to wipe out your whole system. In addition, while some of the commands above require elevated permissions (administrator), they may be disguised in other commands and may trick you into executing them. So always be careful while you are executing the commands and only trust reputed and trusted sources for your command line requirements. The best way is to educate yourselves on how each command works and think through before executing the command.
Vamsi Krishna
Vamsi is a tech and WordPress geek who enjoys writing how-to guides and messing with his computer and software in general. When not writing for MTE, he writes for he shares tips, tricks, and lifehacks on his own blog Stugon.
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox
Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.
Shell Scripting Tutorial: How To Create Shell Script In Linux/Unix
Shell Scripting
Shell Scripting is an open-source computer program designed to be run by the Unix/Linux shell. Shell Scripting is a program to write a series of commands for the shell to execute. It can combine lengthy and repetitive sequences of commands into a single and simple script that can be stored and executed anytime which, reduces programming efforts.
What is Shell?Shell is a UNIX term for an interface between a user and an operating system service. Shell provides users with an interface and accepts human-readable commands into the system and executes those commands which can run automatically and give the program’s output in a shell script.
An Operating is made of many components, but its two prime components are –
Kernel
Shell
Components of Shell Program
A Kernel is at the nucleus of a computer. It makes the communication between the hardware and software possible. While the Kernel is the innermost part of an operating system, a shell is the outermost one.
A shell in a Linux operating system takes input from you in the form of commands, processes it, and then gives an output. It is the interface through which a user works on the programs, commands, and scripts. A shell is accessed by a terminal which runs it.
When you run the terminal, the Shell issues a command prompt (usually $), where you can type your input, which is then executed when you hit the Enter key. The output or the result is thereafter displayed on the terminal.
The Shell wraps around the delicate interior of an Operating system protecting it from accidental damage. Hence the name Shell.
In this Shell Script tutorial, you will learn-
Types of Shell
There are two main shells in Linux:
1. The Bourne Shell: The prompt for this shell is $ and its derivatives are listed below:
POSIX shell also is known as sh
Korn Shell also knew as sh
Bourne Again SHell also knew as bash (most popular)
2. The C shell: The prompt for this shell is %, and its subcategories are:
C shell also is known as csh
Tops C shell also is known as tcsh
We will discuss bash shell based shell scripting in this tutorial.
How to Write Shell Script in Linux/UnixShell Scripts are written using text editors. On your Linux system, open a text editor program, open a new file to begin typing a shell script or shell programming, then give the shell permission to execute your shell script and put your script at the location from where the shell can find it.
Let us understand the steps in creating a Shell Script:
Create a file using a vi editor(or any other editor). Name script file with extension .sh
Start the script with #! /bin/sh
Write some code.
Save the script file as filename.sh
For executing the script type bash filename.sh
“#!” is an operator called shebang which directs the script to the interpreter location. So, if we use”#! /bin/sh” the script gets directed to the bourne-shell.
Let’s create a small script –
#!/bin/sh lsLet’s see the steps to create Shell Script Programs in Linux/Unix –
Steps to Create Shell Script in Linux/Unix
Command ‘ls’ is executed when we execute the scrip chúng tôi file.
Let understand this with an example.
What are Shell Variables?As discussed earlier, Variables store data in the form of characters and numbers. Similarly, Shell variables are used to store information and they can by the shell only.
For example, the following creates a shell variable and then prints it:
variable ="Hello" echo $variableBelow is a small script which will use a variable.
#!/bin/sh echo "what is your name?" read name echo "How do you do, $name?" read remark echo "I am $remark too!"Let’s understand, the steps to create and execute the script
As you see, the program picked the value of the variable ‘name’ as Joy and ‘remark’ as excellent.
Summary:
Kernel is the nucleus of the operating systems, and it communicates between hardware and software
Shell is a program which interprets user commands through CLI like Terminal
The Bourne shell and the C shell are the most used shells in Linux
Linux Shell scripting is writing a series of command for the shell to execute
Shell variables store the value of a string or a number for the shell to read
Shell scripting in Linux can help you create complex programs containing conditional statements, loops, and functions
Basic Shell Scripting Commands in Linux: cat, more, less, head, tail, mkdir, cp, mv, rm, touch, grep, sort, wc, cut and, more.
Update the detailed information about Basics Linux/Unix Commands With Examples & Syntax (List) on the Daihoichemgio.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!