- Linux Hard Disk Format Command
- Step #1 : Partition the new disk using fdisk command
- Step#2 : Format the new disk using mkfs.ext3 command
- Step#3 : Mount the new disk using mount command
- Step#4 : Update /etc/fstab file
- Task: Label the partition
- 40 Essential Linux Commands You Should Know
- Linux Commands For File System Management
- Linux Commands For Text Processing
- Linux Commands For Process Management
- Linux Commands For BASH and User Environment
- Linux Commands For User Management
- Linux Commands Fro Help / Documentation
- Linux Commands For Network
Linux Hard Disk Format Command
Q. I’ve installed a new 250GB SATA hard disk on our office CentOS Linux server. How do I format a hard disk under Linux operating system from a shell prompt?
A. . There are total 4 steps involved for hard disk upgrade and installation procedure:
Step #1 : Partition the new disk using fdisk command
Following command will list all detected hard disks:
# fdisk -l | grep ‘^Disk’
Output:
A device name refers to the entire hard disk. For more information see Linux partition naming convention and IDE drive mappings.
To partition the disk – /dev/sdb, enter:
# fdisk /dev/sdb
The basic fdisk commands you need are:
- m – print help
- p – print the partition table
- n – create a new partition
- d – delete a partition
- q – quit without saving changes
- w – write the new partition table and exit
Step#2 : Format the new disk using mkfs.ext3 command
To format Linux partitions using ext2fs on the new disk:
# mkfs.ext3 /dev/sdb1
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Step#3 : Mount the new disk using mount command
First create a mount point /disk1 and use mount command to mount /dev/sdb1, enter:
# mkdir /disk1
# mount /dev/sdb1 /disk1
# df -H
Step#4 : Update /etc/fstab file
Open /etc/fstab file, enter:
# vi /etc/fstab
Append as follows:
Save and close the file.
Task: Label the partition
You can label the partition using e2label. For example, if you want to label the new partition /backup, enter
# e2label /dev/sdb1 /backup
You can use label name insted of partition name to mount disk using /etc/fstab:
LABEL=/backup /disk1 ext3 defaults 1 2
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
yah thats good for understand………
i have 48TB storage server in raid 5, how do i format this server?
to format the corresponding hdd you need a RAM(Random Access Memory) 1 YB(yota byte)
1YB=1024 ZB
1ZB=1024 XB
1XB=1024 PB
1PB=1024 TB
LOL, I’ve got 1 UB (UnniByte) RAM on my Server
1UB=1024YB
1YB=1024 ZB
1ZB=1024 XB
1XB=1024 PB
1PB=1024 TB
Is it possible to format my 1.4 MB floppy now?
I have 90’90 power of per zylions! So what? You’ve only got a pint of milk. does your processor register .
Use LVM directly or read this tutorial which explains how to create partition larger than 2TB
How do I format a harddisk using linux system call
thank you fro valuable information
how to format a disk by cpp programe?is there any sample code ?
Thank you very much this valuable information.
/dev/sdb1 /disk1 ext3 defaults 1 2
The above line what is mean by defaults and what is 1 2 ?
can u explain those two things !
This is directly from the arch linux (amazing) documentation:
- The first number is “dump”: used by the dump utility to decide when to make a backup. Dump checks the entry and uses the number to decide if a file system should be backed up. Possible entries are 0 and 1. If 0, dump will ignore the file system; if 1, dump will make a backup. Most users will not have dump installed, so they should put 0 for the entry.
- The second number is “pass”: used by fsck to decide which order filesystems are to be checked. Possible entries are 0, 1 and 2. The root file system should have the highest priority 1 – all other file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.
IN my system both WINDOWS-XP and LINUX , I’ve installed. after that
I want to format the linux OS from my system.
so please send to me tricks or method on Email addr., so i can remove LUNUX OS from my system.
BY both method (i)Text command and
(ii)without Text command.
Hey man I also have same problem .did u got any methods to remove . please help man
verrrrrrrrry useful i’ve searched for 2 days for this thanks
Thank you very much this valuable information. Very useful this
Thanks
B. Sathish.
I have installed CentOS ..
now i want my disk to be fully formatted like a new one. with no files on it..
i remember doing it by booting in DOS mode in Win98..
Please tell how can i do it..
Thank you.
nice and clear.
Excellent and easy. Thanx
Nice information and esp. the link that you posted for Anikat. Information really useful pal. Thanks a ton..
Regards
Charanjit Singh Cheema
Thank you, this is the kind of fast reference that one is always looking for
Well, this saved me an hour of banging my head against the wall… well written! thanks!
Yes. Very useful. Thanks.
help me to see the out put of the php programe, i have php 2007 developer
Very simple and useful, thanks 🙂
Great. Searched for a long time to find this, very well done. Thanks!
Can any one tell me what the mean by 1,2 in default and when i create a raid partition is there any change in default charcter or it is sama as ” default” .
IN my Laptop both WINDOWS-XP and LINUX, i’ve safe the problem in windows hal.dll file is corrupted.
so please send to me tricks or method on Email addr.
Good Recipe for what I did in UNIX for years with the simple format command.
You boiled it down to an excellent example…
very helpfull , thanks.
very first command (fdisk /dev/sdb) failed. message is “Unable to open /dev/sdb”. any suggestions?
Is there any software to bound two NIC to use on ip address for both NICs.
Thank you very much these are very good and easy way commands to understand for the people.
how to format linex form my system plz reply solution at my email
thanks alot . that was really usefull
how many formatting for window and linux
plz sand ams on my email address
I deleted the panel in ubuntu by mistake.. how can i get the default panels?
The above steps are so good and easy to format
Thank u Very much for your Formating steps.
a very nice article. thank you for sharing.
how do installed linux …. with command . tell me all command….
IN my system both WINDOWS-XP and LINUX , I’ve installed. after that
I want to format the linux OS from my system.
so please send to me tricks or method on Email addr., so i can remove LUNUX OS from my system.
BY both method (i)Text command and
(ii)without Text command.
Good article.
Note: this works on centos 5.5 … fyi.
This is beautiful. There are some who care out there..
IN my system both WINDOWS-XP and LINUX , I’ve installed. after that
I want to format the linux OS from my system.
so please send to me tricks or method on Email addr., so i can remove LUNUX OS from my system.
BY both method
(i)Text command and
(ii)without Text command.
Источник
40 Essential Linux Commands You Should Know
In the context of operating systems in general, and Linux in particular, the term “command” means either a command line application or functionality built into the user shell. However, to the end user, this distinction is of little consequence. Both are used in the same way. You input words into your terminal emulator, and it outputs the results.
The goal of this article is to list some commands every Linux user should know, or at least know of, in the case of those with a phobia of text-based interfaces. It doesn’t mean to list every useful command, it isn’t a list of the lesser known utilities, and it isn’t a manual. It aims for coverage of the most useful application in day to day life.
As such, it’s divided into several categories, corresponding to particular tasks. It presumes no particular distribution, and while not all the programs described will be installed by default in every distribution, most of them will be present, and the others can be found in the repositories.
Linux Commands For File System Management
1. ls
By default, list the contents of the current directory. If you provide it a path, it will list the contents of that. Useful options to know are -l and -a, a long list format with more information and show hidden (dot) files, respectively.
2. cat
If given a single file, prints its contents to the standard output. If you give it more than one file, it will concatenate them, and you can then redirect the output into a new file. Potentially useful is the -n option, which numbers the lines.
3. cd
Allows you to go from current directory to specified directory. Calling it without arguments returns you to your home directory. Calling it with two dots (cd ..) returns you to a directory “above” the current one, while calling it with a dash (cd -) returns you to the previous directory, regardless of where it’s located relative to the current one.
4. pwd
Prints your current directory. Useful if your prompt doesn’t contain this information, and especially useful in BASH programming for obtaining a reference to the directory in which you’re executing the code.
5. mkdir
Create new directories. The most handy switch is -p, which creates the entire specified structure if it doesn’t exist already.
6. file
Tells you the type of a file. Since files in Linux aren’t under obligation to have extensions for the system to work (not that having extensions always helps), sometimes it’s hard for the user to know what type of file something is, and this little utility solves that problem.
7. cp
Copies files and directories. Since it doesn’t copy directories recursively by default, remember to use -r or -a. The latter preserves mode, ownership and time stamp info in addition to recursively copying.
8. mv
Moves or renames files and directories. Essentially, moving and renaming is one operation – renaming is just “moving” a single file to the same place under a different name.
9. rm
Delete files and directories. Certainly a very useful command to know, as you cannot remove clutter without it. However, beware when using it. Although nowadays you’d really have to work on it to cause some damage to the system, you can still damage yourself – rm doesn’t remove files to some imaginary wastebasket from which you can fish them out later when you realize you’ve made a horrible mistake, and “rm ate my homework” isn’t going to convince anyone. Deleting directories requires recursive operation, so once again we have the -r switch.
10. ln
Creates hard or symbolic links between files. Symbolic or soft links are sort of like Windows shortcuts, they provide a convenient way of accessing a particular file, though the analogy doesn’t quite hold – symlinks can point to anything, but do not feature any metadata. You aren’t very likely to ever use hard links, but knowing they’re aliases to files – as opposed to symlinks, which are aliases to file names – can’t hurt.
11. chmod
Change user permissions. This refers to viewing, writing and executing files. A normal user may change permissions for files he owns.
12. chown
Change file ownership. Only the root user may change the owner of a file. To recursively change the owner for all the files in a directory, use it with -R.
13. find
Search the filesystem for files or directories. Find is a very versatile and powerful command, not only because of its searching capabilities, but also because it allows you to execute arbitrary commands on matching (or non-matching, even) files.
14. locate
Unlike find, locate searches the updatedb database for file name patterns. This database contains a snapshot of the filesystem. This makes locate very fast, but also unreliable – it cannot tell whether anything changed since the last snapshot.
15. du
Show file or directory size. Among the more useful options are -h, which converts the reported sizes into a more human-friendly format, -s which gives only a summary instead of the whole listing, and -d which controls the depth of directory recursion.
16. df
Show disk usage. The default output is good enough – it lists every filesystem, reports its size and the amount of used and available space – but you might want to tack on -h, which once again provides a more human-friendly report.
17. dd
Convert and copy a file, according to its manpage. Not exactly the clearest or most useful description around, and yet, that’s all dd does. You give it a source and a destination, and optionally some other commands, and it copies from one to the other. Its power comes from the flexibility – you can tell it the exact block size, it can copy around corrupted data, and it isn’t picky about devices – if you want to overwrite your hard drive with zeroes straight from /dev/zero, you’re welcome to do it. It’s also commonly used for creating live USB sticks from hybrid ISO images.
18. mount / umount
This pair takes care of mounting and unmounting filesystems. This can range from USB sticks to ISO images. Usually only root has mounting privileges.
Linux Commands For Text Processing
19. more / less
These two similar utilities allow you to view text chunked into screenfuls. Imagine a very long output from some command. Perhaps you called cat on a file and your terminal emulator took a few seconds to scroll all the text. Well, if you pipe it into one of these, you can now scroll it at your leisure. Less is newer and offers more options, so there is no reason to use more.
20. head / tail
Another pair, but here both halves have their uses. Head outputs a number of the first (“head”) lines of a file, while tail outputs a number of last (“tail”) lines of a file. The default number is ten, but this can be controlled via the -n option. Another useful switch is -f, which is short for “follow”, which continually outputs any appended lines – so, for instance, if you wanted to monitor a log file instead of constantly opening and closing it, you could use “tail -f /path/to/logfile”.
21. grep
Grep, like all good Unix tools, does one thing, but does it well. It searches text for patterns. By default it looks at standard input, but you can specify files to be searched. A pattern can be a normal string or a regular expression. It can print out matching or non-matching lines, and their context. Every time you run a command which spews a lot of information you don’t need, pipe it into grep and let it do its magic.
22. sort
Sorts lines of text by various criteria. Among the more useful, there’s -n, which sorts by the numeric value of a string, and -r, which reverses the output. An example of where this might come in handy is sorting du output – for example, if you wanted to see the files sorted in descending order according to size, you’d combine the two options.
23. wc
The command line word counting utility. And line counting. And byte counting. And character counting.
24. diff
Shows the difference between two files via line by line comparison. It only shows altered lines, abbreviating changed as c, deleted as d and added as a.
Linux Commands For Process Management
25. kill / xkill / pkill / killall
All of these serve to “kill” a process, ie terminate it. The difference is what they accept as input. Kill wants the process ID, xkill allows you to click a window to close it, while killall and pkill accept the name of a process, but have somewhat different options and subtly different behavior. Note these do not belong to the same package, and xkill especially is not likely to be installed by default. We advise you to rectify that for your own convenience.
26. ps / pgrep
As mentioned, kill needs the process ID. One way to obtain this is by using ps, which prints information about the currently active processes. The default output is not hugely useful, so stick an -e there to see information about every process on the system. This is only a snapshot, it will not update, see top for that. The pgrep command works in the following manner: you give it a process name, it gives you the process ID. Partial matches count, so be careful.
27. top / htop
These two are similar, both display processes, and can be thought of as console system monitors. We recommend you install htop the first chance you get if your distribution doesn’t ship it by default, as it’s a much improved version of top. For starters, it’s not merely a viewer – it allows you to control processes via its user-friendly console GUI interface.
28. time
Time a process. Think of it as a stopwatch for program execution. Useful if you’re curious how much slower is your homework implementation of a sorting algorithm compared to the built-in one. Contrary to what you might expect based on the name, it doesn’t tell you the time. See date for that.
Linux Commands For BASH and User Environment
29. su / sudo
Su and sudo are two ways of accomplishing the same thing – running a command as another user. Depending on what your distribution is, you’ve likely seen only one or the other, but both are serviceable. The difference is that su switches you to a different user, while sudo only runs the command with another user’s privileges.
30. date
Unlike time, date does exactly what you’d expect it – it prints out the date (and time) to the standard output. The output itself can be formatted to your specification, and it takes everything from the usual stuff like year, month, day,
12 or 24 hour format to nanoseconds and the ISO week number. For example, date +”%j %V” would give you the day of the year followed by the ISO week number.
31. alias
This commands creates or changes aliases to other commands. What this means is, you can give names to new commands (or groupings of commands) or “rename” existing ones. It’s very handy for abbreviating long strings of commands you find yourself using often, or giving more memorable names to things you don’t use that often and have problems memorizing.
32. uname
Outputs some basic system information. By itself, it won’t give you anything very useful (“Linux”), but call it with -a, and it will provide kernel information, as well as tell you the hostname and processor architecture.
33. uptime
Tells you how long has the system been running. Not exactly essential information, but good for bragging rights and the occasional compute-things-relative-to-how-long-I’ve-been-at-the-computer situation.
34. sleep
You might be wondering why or how would this ever be useful, but even outside BASH scripts, it has its uses: for example, if you’d like to shutdown the computer after a certain period of time, or even as a makeshift alarm.
Linux Commands For User Management
35. useradd, userdel, usermod
These commands allow you do add, delete and modify user accounts. It’s not very likely you’ll be using these often, especially if you’re the sole user of your system, and even if not, you might opt for doing this via a GUI, but it’s good to know what they do and that they’re there in case you suddenly need them.
36. passwd
This command enables you to change your user account password. As root, you can reset normal user passwords, though you cannot view them. It’s a good security practice to change your password every so often.
Linux Commands Fro Help / Documentation
37. man / whatis
The man command brings up the manual for a particular command. Most command line applications come with a man page. Whatis provides a one line summary lifted from the relevant sections of the manual. What are sections of the manual? See for yourself with “man man”.
38. whereis
Tells you where an executable binary files lives, provided it’s in your path. It can also find its manual page and source code, provided they are present.
Linux Commands For Network
39. ip
If the list of network related commands seems awfully short, you’re probably not acquainted with ip. In short, the net-utils package which contains ipconfig, netstat and others has been deprecated in favor of the iproute2 package. It provides the ip command, which replaces ipconfig, netstat, route, etc. You could view it as a Swiss Army knife of networking, or a unwanted mess, but either way, it’s the future.
40. ping
Pings are ICMP ECHO_REQUEST datagrams, but that’s not important. The important thing is that the ping utility is a useful diagnostic tool. It allows you to quickly test if you’re connected to your router or the Internet, and gives some indication of the quality of that connection.
Источник