https://wiki.archlinux.org/api.php?action=feedcontributions&user=Chariblaze&feedformat=atomArchWiki - User contributions [en]2024-03-29T12:37:16ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=455449Install Arch Linux from existing Linux2016-10-30T02:18:20Z<p>Chariblaze: Updated title of linked article</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from existing Linux]]<br />
[[ja:既存の Linux からインストール]]<br />
[[pt:Install from existing Linux]]<br />
[[ru:Install from existing Linux]]<br />
[[uk:Install from existing Linux]]<br />
[[zh-cn:Install from existing Linux]]<br />
[[zh-tw:Install from existing Linux]]<br />
{{Related articles start}}<br />
{{Related|Install from SSH}}<br />
{{Related articles end}}<br />
<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the existing system without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which the scripts from {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-chroot}}) can be run.<br />
<br />
If the host system runs Arch Linux, this can be achieved by simply installing {{Pkg|arch-install-scripts}}. If the host system runs another Linux distribution, you will first need to set up an Arch Linux-based chroot.<br />
<br />
{{Note|This guide requires that the existing host system be able to execute the new target Arch Linux architecture programs. In the case of an x86_64 host, it is possible to use i686-pacman to build a 32-bit chroot environment. See [[Install bundled 32-bit system in 64-bit system]]. However it is not so easy to build a 64-bit environment when the host only supports running 32-bit programs.}}<br />
<br />
{{Warning|Please make sure you understand each step before proceeding. It is easy to destroy your system or to lose critical data, and your service provider will likely charge a lot to help you recover. }}<br />
<br />
==Backup and Preparation==<br />
Backup all your data including mails, webservers, etc. Have all information at your fingertips. Preserve all your server configurations, hostnames, etc.<br />
<br />
Here is a list of data you will likely need:<br />
* IP address<br />
* hostname(s), (note: rootserver are mostly also part of the providers domain, check or save your {{ic|/etc/hosts}} before you delete)<br />
* DNS server (check {{ic|/etc/resolv.conf}})<br />
* SSH keys (if other people work on your server, they will have to accept new keys otherwise. This includes keys from your Apache, your mail servers, your SSH server and others.)<br />
* Hardware info (network card, etc. Refer to your pre-installed {{ic|/etc/modules.conf}} )<br />
* Grub configuration files.<br />
<br />
In general, it is a good idea to have a local copy of your original {{ic|/etc}} directory on your local hard drive.<br />
<br />
== From a host running Arch Linux ==<br />
<br />
Install the {{Pkg|arch-install-scripts}} package.<br />
<br />
Follow [[Installation guide#Mount the file systems]]. If you already use the {{ic|/mnt}} directory for something else, just create another directory such as {{ic|/mnt/install}}, and use that instead.<br />
<br />
Then follow [[Installation guide#Installation]]. You can skip [[Installation guide#Select the mirrors]], since the host should already have a correct mirrorlist.<br />
<br />
{{Tip|In order to avoid redownloading all the packages, consider following [[Pacman/Tips and tricks#Network shared pacman cache]] or using ''pacstrap'''s {{ic|-c}} option.}}<br />
<br />
{{Merge|Moving_an_existing_install_into_(or_out_of)_a_virtual_machine#Moving_into_a_VM|Same approach.}}<br />
<br />
{{Note|If you only want to create an exact copy of an existing Arch installation, it is also possible to just copy the filesystem to the new partition. With this method, you will still need to<br />
<br />
* Create [[Installation guide#Fstab|{{ic|/etc/fstab}}]] and edit {{ic|/etc/hostname}}<br />
* Delete {{ic|/etc/machine-id}} so that a new, unique, one will be regenerated on boot<br />
* Make any other changes appropriate to the installation medium<br />
* Install the bootloader<br />
<br />
When copying the filesystem root, use something like {{ic|cp -ax}} or {{ic|rsync -axX}}. This avoids copying contents of mountpoints ({{ic|-x}}), and preserves the [[capabilities]] attributes of some system binaries ({{ic|rsync -X}}).<br />
}}<br />
<br />
== From a host running another Linux distribution ==<br />
<br />
There are multiple tools which automate a large part of the steps described in the following subsections. See their respective homepages for detailed instructions.<br />
<br />
* [https://github.com/tokland/arch-bootstrap arch-bootstrap] (Bash)<br />
* [https://github.com/hartwork/image-bootstrap image-bootstrap] (Python)<br />
* [https://github.com/drizzt/vps2arch vps2arch] (Bash)<br />
* [https://github.com/m4rienf/ArchCX archcx] (Bash, from Hetzner CX Rescue System)<br />
<br />
The manual way is presented in the following subsections. The idea is to run an Arch system inside the host system, with the actual installation being executed from the Arch system. The nested system is contained inside a chroot.<br />
<br />
=== Creating the chroot ===<br />
<br />
Two methods to setup and enter the chroot are presented below, from the easiest to the most complicated. Select only one of the two methods. Then, continue at [[#Using the chroot environment]].<br />
<br />
==== Method A: Using the bootstrap image (recommended) ====<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
# cd /tmp<br />
# curl -O https://mirrors.kernel.org/archlinux/iso/2016.09.03/archlinux-bootstrap-2016.09.03-x86_64.tar.gz<br />
<br />
You can also download the signature (same URL with {{ic|.sig}} added) and [[GnuPG#Verify_a_signature|verify it with GnuPG]].<br />
<br />
Extract the tarball:<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2016.09.03-x86_64.tar.gz<br />
<br />
Select a repository server by editing {{ic|/tmp/root.x86_64/etc/pacman.d/mirrorlist}}.<br />
<br />
{{Note|If bootstrapping an i686 image from an x86_64 host system, also edit {{Ic|/tmp/root.i686/etc/pacman.conf}} and explicitly define {{Ic|1=Architecture = i686}} in order for pacman to pull the proper i686 packages.}}<br />
<br />
Enter the chroot<br />
<br />
* If bash 4 or later is installed, and unshare supports the --fork and --pid options:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Otherwise, run the following commands:<br />
# mount --bind /tmp/root.x86_64 /tmp/root.x86_64<br />
# cd /tmp/root.x86_64<br />
# cp /etc/resolv.conf etc<br />
# mount -t proc /proc proc<br />
# mount --rbind /sys sys<br />
# mount --rbind /dev dev<br />
# mount --rbind /run run # (assuming /run exists on the system)<br />
# chroot /tmp/root.x86_64 /bin/bash<br />
<br />
==== Method B: Using the LiveCD image ====<br />
<br />
It is possible to mount the root image of the latest Arch Linux installation media and then chroot into it. This method has the advantage of providing a working Arch Linux installation right within the host system without the need to prepare it by installing specific packages.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise, errors like the following are to be expected: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download mirrors] under either arch/x86_64/ or arch/i686/, depending on the desired architecture. The squashfs format is not editable, so we unsquash the root image and mount it.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs airootfs.sfs}}<br />
<br />
* Before [[Change root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount --bind squashfs-root squashfs-root<br />
# mount -t proc none squashfs-root/proc<br />
# mount -t sysfs none squashfs-root/sys<br />
# mount -o bind /dev squashfs-root/dev<br />
# mount -o bind /dev/pts squashfs-root/dev/pts ## important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf squashfs-root/etc ## this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now, everything is prepared to chroot into the newly installed Arch environment<br />
{{bc|# chroot squashfs-root bash}}<br />
<br />
=== Using the chroot environment ===<br />
<br />
The bootstrap environment is really barebones (no {{ic|nano}}, no {{ic|ping}}, no {{ic|cryptsetup}}, no {{ic|lvm}}). Therefore, we need to set up [[pacman]] in order to download the rest of the {{ic|base}} and, if needed, {{ic|base-devel}}.<br />
<br />
==== Initializing pacman keyring ====<br />
<br />
Before starting the installation, pacman keys need to be setup. Before running the following two commands, read [[pacman-key#Initializing the keyring]] to understand the entropy requirements:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
{{Tip|Installing and running {{Pkg|haveged}} must be done on the host system, since it is not possible to install packages before initializing pacman keyring and because ''systemd'' will detect it is running in a chroot and [https://superuser.com/questions/688733/start-a-systemd-service-inside-chroot ignore activation request].<br />
<br />
If you go with doing {{ic|ls -Ra /}} in another console (TTY, terminal, SSH session...), do not be afraid of running it in a loop a few times: five or six runs from the host proved sufficient to generate enough entropy on a remote headless server.}}<br />
<br />
==== Selecting a mirror and downloading basic tools ====<br />
<br />
After [[Mirrors#Enabling_a_specific_mirror|selecting a mirror]], [[Mirrors#Force_pacman_to_refresh_the_package_lists|refresh the package lists]] and [[install]] what you need: {{Grp|base}}, {{Grp|base-devel}}, {{Pkg|parted}} etc.<br />
<br />
=== Installation tips ===<br />
<br />
You can now proceed to [[Installation_guide#Partition_the_disks]] and follow the rest of the [[Installation guide]].<br />
<br />
Some host systems or configurations may require certain extra steps. See the sections below for tips.<br />
<br />
===== Debian-based host =====<br />
<br />
====== /dev/shm ======<br />
<br />
On some Debian-based host systems, {{ic|pacstrap}} may produce the following error:<br />
<br />
{{hc|# pacstrap /mnt base|<br />
==> Creating install root at /mnt<br />
mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
==> ERROR: failed to setup API filesystems in new root<br />
}}<br />
<br />
This is because in some versions of Debian, {{ic|/dev/shm}} points to {{ic|/run/shm}} while in the Arch-based chroot, {{ic|/run/shm}} does not exist and the link is broken. To correct this error, create a directory {{ic|/run/shm}}:<br />
# mkdir /run/shm<br />
<br />
====== /dev/pts ======<br />
<br />
While installing {{ic|archlinux-2015.07.01-x86_64}} from a Debian 7 host, the following error prevented both [https://projects.archlinux.org/arch-install-scripts.git/tree/pacstrap.in pacstrap] and [[Change_root#Using_arch-chroot|arch-chroot]] from working:<br />
<br />
{{hc|# pacstrap -i /mnt|<br />
mount: mount point /mnt/dev/pts does not exist<br />
==> ERROR: failed to setup chroot /mnt<br />
}}<br />
<br />
Apparently, this is because these two scripts use a common function. {{ic|chroot_setup()}}[https://projects.archlinux.org/arch-install-scripts.git/tree/common#n76] relies on newer features of {{Pkg|util-linux}}, which are incompatible with Debian 7 userland (see {{Bug|45737}}).<br />
<br />
The solution for ''pacstrap'' is to manually execute its [https://projects.archlinux.org/arch-install-scripts.git/tree/pacstrap.in#n77 various tasks], but use the [[Change_root#Using_chroot|regular procedure]] to mount the kernel filesystems on the target directory ({{ic|"$newroot"}}):<br />
<br />
{{bc|1=<br />
# newroot=/mnt<br />
# mkdir -m 0755 -p "$newroot"/var/{cache/pacman/pkg,lib/pacman,log} "$newroot"/{dev,run,etc}<br />
# mkdir -m 1777 -p "$newroot"/tmp<br />
# mkdir -m 0555 -p "$newroot"/{sys,proc}<br />
# mount --bind "$newroot" "$newroot"<br />
# mount -t proc /proc "$newroot/proc"<br />
# mount --rbind /sys "$newroot/sys"<br />
# mount --rbind /run "$newroot/run"<br />
# mount --rbind /dev "$newroot/dev"<br />
# pacman -r "$newroot" --cachedir="$newroot/var/cache/pacman/pkg" -Sy base base-devel ... ## add the packages you want<br />
# cp -a /etc/pacman.d/gnupg "$newroot/etc/pacman.d/" ## copy keyring<br />
# cp -a /etc/pacman.d/mirrorlist "$newroot/etc/pacman.d/" ## copy mirrorlist<br />
}}<br />
<br />
Instead of using {{ic|arch-chroot}} for [[Installation guide#Chroot]], simply use {{ic|chroot "$newroot"}}.<br />
<br />
====== lvmetad ======<br />
<br />
Trying to create [[LVM]] [[LVM#Logical_volumes|logical volumes]] from an {{ic|archlinux-bootstrap-2015.07.01-x86_64}} environment on a Debian 7 host resulted in the following error:<br />
<br />
{{hc|# lvcreate -L 20G lvm -n root|<br />
/run/lvm/lvmetad.socket: connect failed: No such file or directory<br />
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.<br />
/dev/lvm/root: not found: device not cleared<br />
Aborting. Failed to wipe start of new LV.}}<br />
<br />
(Physical volume and volume group creation worked despite {{ic|/run/lvm/lvmetad.socket: connect failed: No such file or directory}} being displayed.)<br />
<br />
This could be easily worked around by creating the logical volumes outside the chroot (from the Debian host). They are then available once chrooted again.<br />
<br />
{{Accuracy|This problem did not arise when installing from a Debian 7 host without lvmetad enabled. The recommended messaround with {{ic|/etc/lvm/lvm.conf}} looks rather error prone (2015-07-26).}}<br />
{{Style|Language and formatting are lacking, links to relevant articles in the wiki as well.}}<br />
<br />
Also, if the system you are using has lvm, you might have the following output:<br />
<br />
{{hc|1=# grub-install --target=i386-pc --recheck /dev/mapper/main-archroot|2=<br />
Installing for i386-pc platform.<br />
/run/lvm/lvmetad.socket: connect failed: No such file or directory<br />
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.<br />
/run/lvm/lvmetad.socket: connect failed: No such file or directory<br />
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.<br />
/run/lvm/lvmetad.socket: connect failed: No such file or directory<br />
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.<br />
/run/lvm/lvmetad.socket: connect failed: No such file or directory<br />
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.<br />
/run/lvm/lvmetad.socket: connect failed: No such file or directory<br />
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.<br />
}}<br />
<br />
This is because debian does not use lvmetad by default. You need to edit {{ic|/etc/lvm/lvm.conf}} and set {{ic|use_lvmetad}} to {{ic|0}}:<br />
<br />
use_lvmetad = 0<br />
<br />
This will trigger later an error on boot in the initrd stage. Therefore, you have to change it back after the grub generation. In a software RAID + LVM, steps would be the following:<br />
<br />
* After installing all the system, when you have to do all the initramfs (mkinitcpio) and grub thing.<br />
* Change /etc/mdadm.conf to reflect your RAID config (if any)<br />
* Change HOOKS and MODULES according to lvm and raid requirements: {{ic|1=MODULES="dm_mod" HOOKS="base udev '''mdadm_udev''' ... block '''lvm2''' filesystems ..."}}<br />
* Generate initrd images with mkinitcpio<br />
* Change /etc/lvm/lvm.conf to put use_lvmetad = 0<br />
* Generate grub config (grub-mkconfig)<br />
* Change /etc/lvm/lvm.conf to put use_lvmetad = 1<br />
<br />
===== Fedora-based host =====<br />
<br />
On Fedora based hosts and live USBs you may encounter problems when using {{ic|genfstab}} to generate your [[fstab]]. Remove duplicate entries and the "seclabel" option where it appears, as this is Fedora-specific and will keep your system from booting normally.<br />
<br />
== Things to check before you reboot==<br />
<br />
Before rebooting, chroot into the newly-installed system.<br />
<br />
Set a root password so that you can log in with ssh later:<br />
# passwd<br />
<br />
Install [[ssh]] and [[enable]] it to start automatically at boot.<br />
<br />
Configure the [[network]] connection to start automatically at boot.<br />
<br />
Set up a [[boot loader]] and configure it to use the swap partition you appropriated earlier as the root partition. You might want to configure your bootloader to be able to boot into your old system; it is helpful to re-use the server's existing /boot partition in the new system for this purpose.<br />
<br />
== Replacing the existing system without a LiveCD ==<br />
<br />
Find ~700MB of free space somewhere on the disk, e.g. by partitioning a swap partition. You can disable the swap partition and set up your system there. <br />
<br />
===Set old swap partition as new root partition===<br />
<br />
Check {{ic|cfdisk}}, {{ic|/proc/swaps}} or {{ic|/etc/fstab}} to find your swap partition. Assuming your hard drive is located on sdaX (X will be a number). <br />
<br />
Do the following:<br />
<br />
Disable the swap space:<br />
# swapoff /dev/sdaX<br />
<br />
Create a filesystem on it<br />
# fdisk /dev/sda<br />
(set /dev/sdaX ID field to "Linux" - Hex 83)<br />
# mke2fs -j /dev/sdaX<br />
<br />
Create a directory to mount it in<br />
# mkdir /mnt/newsys<br />
<br />
Finally, mount the new directory for installing the intermediate system.<br />
# mount -t ext4 /dev/sdaX /mnt/newsys<br />
<br />
=== Installation ===<br />
If less than 700MB are available, examine the packages in the group base, and select only those required to get a system with internet connection up and running in the temporary partition. This will mean explicitly specifying individual packages to pacstrap, as well as passing it the -c option, to get packages downloaded to the host system to avoid filling up valuable space.<br />
<br />
Once the new Arch Linux system is installed, reboot into the newly created system, and [[Full system backup with rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Chariblazehttps://wiki.archlinux.org/index.php?title=Talk:Arch_Linux_Archive&diff=455448Talk:Arch Linux Archive2016-10-30T02:13:11Z<p>Chariblaze: /* "No listing allowed here" when accessing magic subdirectory .all */ new section</p>
<hr />
<div>== "No listing allowed here" when accessing magic subdirectory .all ==<br />
<br />
"You can use the magic subdirectory .all to access all packages by their name. It acts as a flat directory containing all versions of every package."<br />
<br />
https://archive.archlinux.org/packages/.all/<br />
<br />
"No listing allowed here."<br />
<br />
<br />
Is there an alternative?</div>Chariblazehttps://wiki.archlinux.org/index.php?title=Powerpill&diff=455447Powerpill2016-10-30T02:05:53Z<p>Chariblaze: totally 200 megs > totaling 200 megs</p>
<hr />
<div>[[Category:Package management]]<br />
[[it:Powerpill]]<br />
[[ja:Powerpill]]<br />
[[ru:Powerpill]]<br />
Powerpill is a Pacman wrapper that uses parallel and segmented downloading to try to speed up downloads for Pacman. Internally it uses Aria2 and Reflector to achieve this. Powerpill can also use Rsync for official mirrors that support it. This can be efficient for users who already use full bandwidth when downloading from a single mirror. [[Pacserve]] is also supported via the configuration file and will be used before downloading from external mirrors. Example: One wants to update and issues a ''pacman -Syu'' which returns a list of 20 packages that are available for update totaling 200 megs. If the user downloads them via pacman, they will come down one-at-a-time. If the user downloads them via powerpill, they will come down simultaneously in many cases several times faster (depending on one's connection speed, the availability of packages on servers, and speed from server/load, etc.)<br />
<br />
A test of pacman vs. powerpill on one system revealed a 4x speed up in the above scenario where the pacman downloads averages 300 kB/sec and the powerpill downloads averaged 1.2 MB/sec.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{AUR|powerpill}} package.<br />
<br />
== Configuration ==<br />
<br />
Powerpill has a single configure file {{ic|/etc/powerpill/powerpill.json}} you can edit to your liking. Refer to the ''powerpill.json'' man page for details.<br />
<br />
== Using Reflector ==<br />
<br />
By default, Powerpill is configured to use [[Reflector]] to retrieve the current list of mirrors from the Arch Linux server's web API and use them for parallel downloads. This is to make sure that there are enough servers in the list for significant speed improvements.<br />
<br />
== Using rsync ==<br />
<br />
Rsync support is available for some mirrors. When enabled, database synchronizations ({{ic|pacman -Sy}}) and other operations may be much faster because a single connection is used. The ''rsync'' protocol itself also speeds up update checks and sometimes file transfers.<br />
<br />
To find a suitable mirror with ''rsync'' support, use ''reflector'':<br />
<br />
$ reflector -p rsync<br />
<br />
Alternatively, you can use this to filter the fastest ''n'' number of servers (option {{ic|-f}}) as well as the ''m'' number of most recently updated servers (option {{ic|-l}}):<br />
<br />
$ reflector -p rsync -f ''n'' -l ''m''<br />
<br />
Select the mirror(s) you want to use. The {{ic|-c}} option may also be used to filter by your nationality ({{ic|reflector --list-countries}} to see a complete list, use quotes around the name, and this is case-sensitive!). Once done, edit {{ic|/etc/powerpill/powerpill.json}}, scroll down to the ''rsync'' section, and add as many servers as you would like to the server field.<br />
<br />
After that, all official database and packages will be downloaded from the ''rsync'' server whenever possible.<br />
<br />
== Basic usage ==<br />
<br />
For most operations, ''powerpill'' works just like pacman since it is a wrapper script for ''pacman''.<br />
<br />
=== System updating ===<br />
<br />
To update your system (sync and update installed packages) using powerpill, simply pass the {{ic|-Syu}} options to it as you would with ''pacman'':<br />
<br />
# powerpill -Syu<br />
<br />
=== Installation of packages ===<br />
<br />
To install a package and its deps, simply use powerpill with the {{ic|-S}} option as you would with ''pacman'':<br />
<br />
# powerpill -S ''package''<br />
<br />
You may also install multiple packages with it the same way you would with ''pacman'':<br />
<br />
# powerpill -S ''package1'' ''package2'' ''package3''<br />
<br />
== Troubleshooting ==<br />
<br />
In case you get an [err] for <repo>.db.sig files:<br />
<br />
b5d7d7|ERR | 0B/s|/var/lib/pacman/sync/extra.db.sig<br />
899e91|ERR | 0B/s|/var/lib/pacman/sync/multilib.db.sig<br />
8fcc32|ERR | 0B/s|/var/lib/pacman/sync/core.db.sig<br />
85eb3d|ERR | 0B/s|/var/lib/pacman/sync/community.db.sig<br />
<br />
It is because signature files are missing for that repo and you have not set:<br />
<br />
SigLevel = PackageRequired<br />
<br />
explicity in {{ic|/etc/pacman.conf}} as explained in this post [https://bbs.archlinux.org/viewtopic.php?pid=1254940#p1254940 Arch forum post]<br />
<br />
== See also ==<br />
<br />
* [http://xyne.archlinux.ca/projects/powerpill/ Powerpill] - official project page<br />
* [https://bbs.archlinux.org/viewtopic.php?id=153818 powerpill reborn] - powerpill is back :)</div>Chariblazehttps://wiki.archlinux.org/index.php?title=Core_utilities&diff=455436Core utilities2016-10-29T23:49:44Z<p>Chariblaze: mv's -i option makes it ask for confirmation before overwriting any number of files, not just 3 or more.</p>
<hr />
<div>[[Category:System administration]]<br />
[[Category:Command shells]]<br />
[[fa:Core utilities]]<br />
[[es:Core utilities]]<br />
[[it:Core utilities]]<br />
[[ja:Core Utilities]]<br />
[[ko:Core utilities]]<br />
[[ru:Core utilities]]<br />
[[zh-cn:Core utilities]]<br />
[[zh-tw:Core utilities]]<br />
{{Related articles start}}<br />
{{Related|Bash}}<br />
{{Related|Zsh}}<br />
{{Related|General recommendations}}<br />
{{Related|GNU Project}}<br />
{{Related|sudo}}<br />
{{Related|cron}}<br />
{{Related|man page}}<br />
{{Related|Securely wipe disk#shred}}<br />
{{Related|File permissions and attributes}}<br />
{{Related|Color output in console}}<br />
{{Related articles end}}<br />
<br />
This article deals with so-called ''core'' utilities on a GNU/Linux system, such as ''less'', ''ls'', and ''grep''. The scope of this article includes, but is not limited to, those utilities included with the GNU {{Pkg|coreutils}} package. What follows are various tips and tricks and other helpful information related to these utilities.<br />
<br />
== Basic commands ==<br />
<br />
The following table lists basic shell commands every Linux user should be familiar with. Commands in '''bold''' are part of the shell, others are separate programs called from the shell. See the below sections and ''Related articles'' for details.<br />
<br />
{| class="wikitable"<br />
! Command<br />
! Description<br />
! Manual page<br />
! Example<br />
|-<br />
| man<br />
| Show manual page for a command<br />
| {{man|7|man}}<br />
| man ed<br />
|-<br />
| '''cd'''<br />
| Change directory<br />
| {{man|1|cd}}<br />
| cd /etc/pacman.d<br />
|-<br />
| mkdir<br />
| Create a directory<br />
| {{man|1|mkdir}}<br />
| mkdir ~/newfolder<br />
|-<br />
| rmdir<br />
| Remove empty directory<br />
| {{man|1|rmdir}}<br />
| rmdir ~/emptyfolder<br />
|-<br />
| rm<br />
| Remove a file<br />
| {{man|1|rm}}<br />
| rm ~/file.txt<br />
|-<br />
| rm -r<br />
| Remove directory and contents<br />
|<br />
| rm -r ~/.cache<br />
|-<br />
| ls<br />
| List files<br />
| {{man|1|ls}}<br />
| ls *.mkv<br />
|-<br />
| ls -a<br />
| List hidden files<br />
|<br />
| ls -a /home/archie<br />
|-<br />
| ls -al<br />
| List hidden files and file properties<br />
|<br />
|<br />
|-<br />
| mv<br />
| Move a file<br />
| {{man|1|mv}}<br />
| mv ~/compressed.zip ~/archive/compressed2.zip<br />
|-<br />
| cp<br />
| Copy a file<br />
| {{man|1|cp}}<br />
| cp ~/.bashrc ~/.bashrc.bak<br />
|-<br />
| chmod +x<br />
| Make a file executable<br />
| {{man|1|chmod}}<br />
| chmod +x ~/.local/bin/myscript.sh<br />
|-<br />
| cat<br />
| Show file contents<br />
| {{man|1|cat}}<br />
| cat /etc/hostname<br />
|-<br />
| strings<br />
| Show printable characters in binary files<br />
| {{man|1|strings}}<br />
| strings /usr/bin/free<br />
|-<br />
| find<br />
| Search for a file<br />
| {{man|1|find}}<br />
| find ~ -name myfile<br />
|-<br />
| mount<br />
| Mount a partition<br />
| {{man|8|mount}}<br />
| mount /dev/sdc1 /media/usb<br />
|-<br />
| df -h<br />
| Show remaining space on all partitions<br />
| {{man|1|df}}<br />
|<br />
|-<br />
| ps -A<br />
| Show all running processes<br />
| {{man|1|ps}}<br />
|<br />
|-<br />
| killall<br />
| Kill all running instances of a process<br />
| {{man|1|killall}}<br />
|<br />
|-<br />
| ss -at<br />
| Display a list of open TCP sockets<br />
| {{man|8|ss}}<br />
|<br />
|}<br />
<br />
== cat ==<br />
<br />
[[Wikipedia:cat_(Unix)|cat]] is a standard Unix utility that concatenates and lists files.<br />
<br />
* Because ''cat'' is not a built-in shell, on many occasions you may find it more convenient to use a [[Wikipedia:Redirection (computing)|redirection]], for example in scripts, or if you care a lot about performance. In fact {{ic|< ''file''}} does the same as {{ic|cat ''file''}}.<br />
<br />
* ''cat'' is able to work with multiple lines:<br />
<br />
{{bc|<br />
$ cat << EOF >> ''path/file''<br />
''first line''<br />
...<br />
''last line''<br />
EOF<br />
}}<br />
<br />
Alternatively, using {{ic|printf}}:<br />
<br />
{{bc|<br />
$ printf '%s\n' 'first line' ... 'last line'<br />
}}<br />
<br />
* If you need to list file lines in reverse order, there is a utility called [[Wikipedia:tac (Unix)|tac]] (''cat'' reversed).<br />
<br />
== dd ==<br />
<br />
[[Wikipedia:dd (Unix)|dd]] is a utility for Unix and Unix-like operating systems whose primary purpose is to convert and copy a file.<br />
<br />
Similarly to ''cp'', by default ''dd'' makes a bit-to-bit copy of the file, but with lower-level I/O flow control features.<br />
<br />
{{Tip|By default, ''dd'' outputs nothing until the task has finished. To monitor the progress of the operation, add the {{ic|1=status=progress}} option to the command.}}<br />
<br />
'dd' can be used to:<br />
* [[Disk_cloning#Using_dd|drive-related]] tasks:<br />
** Create an image.<br />
** Write an image.<br />
** Clone whole drive, or partition.<br />
** Wipe drive or partition.<br />
** Erase partition table or boot sector.<br />
** Backup boot sector.<br />
** Restore system.<br />
* Get stream from device, {{ic|dd /dev/random}}, or some input device.<br />
* Create load on CPU (example: {{ic|1=dd if=/dev/zero of=/dev/null}}).<br />
* Create load on disk (example: {{ic|1=dd if=/dev/zero of=/''path''/''testfile'' bs=''number_of''G count=''times'' oflag=''fdatasync''}}).<br />
* Create I/O load on disk (many rapid read/writes) (example above with little block size ({{ic|bs}}) and big amount of cycles ({{ic|count}}) and needed {{ic|oflag}}, based on what and how you want to test).<br />
* As a backup utility or part of solution.<br />
* Convert a file to upper/lower case.<br />
<br />
For more information see {{man|1|dd}} or the [http://www.gnu.org/software/coreutils/dd full documentation].<br />
<br />
== grep ==<br />
<br />
[[Wikipedia:grep|grep]] (from [[Wikipedia:ed|ed]]'s ''g/re/p'', ''global/regular expression/print'') is a command line text search utility originally written for Unix. The ''grep'' command searches files or standard input for lines matching a given regular expression, and prints these lines to the program's standard output.<br />
<br />
* Remember that ''grep'' handles files, so a construct like {{ic|cat ''file'' <nowiki>|</nowiki> grep ''pattern''}} is replaceable with {{ic|grep ''pattern'' ''file''}}<br />
* There are ''grep'' alternatives optimized for VCS source code, such as {{Pkg|the_silver_searcher}} and {{Pkg|ack}}.<br />
* To include file line numbers in the output, use the {{ic|-n}} option. <br />
<br />
{{Note|Some commands send their output to {{man|3|stderr}}, and grep has no apparent effect. In this case, redirect ''stderr'' to ''stdout'' with {{ic|''command'' 2>&1 {{!}} grep ''args''}} or (for Bash 4) {{ic|''command'' {{!}}& grep ''args''}}. See also [http://www.tldp.org/LDP/abs/html/io-redirection.html I/O Redirection].}}<br />
<br />
For color support, see [[Color output in console#grep]].<br />
<br />
== find ==<br />
<br />
''find'' is part of the {{Pkg|findutils}} package, which belongs to the {{Grp|base}} package group. <br />
<br />
One would probably expect a ''find'' command to take as argument a file name and search the filesystem for files matching that name. For a program that does exactly that see [[#locate]] below. <br />
<br />
Instead, find takes a set of directories and matches each file under them against a set of expressions. This design allows for some very powerful "one-liners" that would not be possible using the "intuitive" design described above. See [http://mywiki.wooledge.org/UsingFind UsingFind] for usage details.<br />
<br />
== iconv ==<br />
<br />
''iconv'' converts the encoding of characters from one codeset to another.<br />
<br />
The following command will convert the file {{ic|foo}} from ISO-8859-15 to UTF-8 saving it to {{ic|foo.utf}}:<br />
<br />
$ iconv -f ISO-8859-15 -t UTF-8 foo >foo.utf<br />
<br />
See {{ic|man iconv}} for more details.<br />
<br />
=== Convert a file in place ===<br />
<br />
{{Tip|You can use {{pkg|recode}} instead of iconv if you do not want to touch the mtime.}}<br />
Unlike [[#sed|sed]], ''iconv'' does not provide an option to convert a file in place. However, {{ic|sponge}} can be used to handle it, it comes with {{pkg|moreutils}}.<br />
<br />
$ iconv -f WINDOWS-1251 -t UTF-8 foobar.txt | sponge foobar.txt<br />
<br />
See {{ic|man sponge}} for details.<br />
<br />
== ip ==<br />
<br />
[[Wikipedia:Iproute2|ip]] allows you to show information about network devices, IP addresses, routing tables, and other objects in the Linux [[Wikipedia:Internet Protocol|IP]] software stack. By appending various commands, you can also manipulate or configure most of these objects.<br />
<br />
{{Note|The ''ip'' utility is provided by the {{Pkg|iproute2}} package, which is included in the {{Grp|base}} group.}}<br />
<br />
{| class="wikitable"<br />
! Object !! Purpose !! Manual page<br />
|-<br />
| ip addr || protocol address management || {{man|8|ip-address|url=}}<br />
|-<br />
| ip addrlabel || protocol address label management || {{man|8|ip-addrlabel}}<br />
|-<br />
| ip l2tp || tunnel Ethernet over IP (L2TPv3) || {{man|8|ip-l2tp}}<br />
|-<br />
| ip link || network device configuration || {{man|8|ip-link|url=}}<br />
|-<br />
| ip maddr || multicast addresses management || {{man|8|ip-maddress}}<br />
|-<br />
| ip monitor || watch for netlink messages || {{man|8|ip-monitor}}<br />
|-<br />
| ip mroute || multicast routing cache management || {{man|8|ip-mroute}}<br />
|-<br />
| ip mrule || rule in multicast routing policy db ||<br />
|-<br />
| ip neigh || neighbour/ARP tables management || {{man|8|ip-neighbour}}<br />
|-<br />
| ip netns || process network namespace management || {{man|8|ip-netns}}<br />
|-<br />
| ip ntable || neighbour table configuration || {{man|8|ip-ntable}}<br />
|-<br />
| ip route || routing table management || {{man|8|ip-route|url=}}<br />
|-<br />
| ip rule || routing policy database management || {{man|8|ip-rule}}<br />
|-<br />
| ip tcp_metrics || management for TCP Metrics || {{man|8|ip-tcp_metrics}}<br />
|-<br />
| ip tunnel || tunnel configuration || {{man|8|ip-tunnel}}<br />
|-<br />
| ip tuntap || manage TUN/TAP devices ||<br />
|-<br />
| ip xfrm || manage IPsec policies || {{man|8|ip-xfrm}}<br />
|}<br />
<br />
The {{ic|help}} command is available for all objects. For example, typing {{ic|ip addr help}} will show you the command syntax available for the address object. For advanced usage see the [http://www.policyrouting.org/iproute2.doc.html iproute2 documentation].<br />
<br />
The [[Network configuration]] article shows how the ''ip'' command is used in practice for various common tasks.<br />
<br />
{{Note|You might be familiar with the [[Wikipedia:ifconfig|ifconfig]] command, which was used in older versions of Linux for interface configuration. It is now deprecated in Arch Linux; you should use ''ip'' instead. }}<br />
<br />
== locate ==<br />
<br />
[[Install]] the {{Pkg|mlocate}} package. After installation a script is automatically scheduled to run a daily task to update its database. You can also manually run ''updatedb'' as root at any time. By default, paths such as {{ic|/media}} and {{ic|/mnt}} are ignored, so ''locate'' may not discover files on external devices. See {{man|1| updatedb}} for details.<br />
<br />
The ''locate'' command is a common Unix tool for quickly finding files by name. It offers speed improvements over the [[wikipedia:Find|find]] tool by searching a pre-constructed database file, rather than the filesystem directly. The downside of this approach is that changes made since the construction of the database file cannot be detected by ''locate''. This problem is minimised by regular, typically scheduled use of the ''updatedb'' command, which (as the name suggests) updates the database.<br />
<br />
Before ''locate'' can be used, the database will need to be created. To do this, execute {{ic|updatedb}} as root.<br />
<br />
See also [http://jvns.ca/blog/2015/03/05/how-the-locate-command-works-and-lets-rewrite-it-in-one-minute/ How locate works and rewrite it in one minute].<br />
<br />
== less ==<br />
<br />
{{Expansion|less is a complex beast, and this section should explain some of the basic less commands}}<br />
<br />
[[Wikipedia:less (Unix)|less]] is a terminal pager program used to view the contents of a text file one screen at a time. Whilst similar to other pagers such as [[Wikipedia:more (command)|more]] and [[Wikipedia:pg (Unix)|pg]], ''less'' offers a more advanced interface and complete [http://www.greenwoodsoftware.com/less/faq.html feature-set].<br />
<br />
See [[List of applications#Terminal pagers]] for alternatives.<br />
<br />
=== Vim as alternative pager ===<br />
<br />
[[Vim]] includes a script to view the content of text files, compressed files, binaries, directories. Add the following line to your shell configuration file to use it as a pager:<br />
{{hc|~/.bashrc|2=alias less='/usr/share/vim/vim74/macros/less.sh'}}<br />
<br />
There is also an alternative to ''less.sh'' macro, which may work as the {{ic|PAGER}} environment variable. Install {{Pkg|vimpager}} and add the following to your shell configuration file:<br />
{{hc|~/.bashrc|2=<br />
export PAGER='vimpager'<br />
alias less=$PAGER<br />
}}<br />
<br />
Now programs that use the {{ic|PAGER}} environment variable, like [[git]], will use ''vim'' as pager.<br />
<br />
== ls ==<br />
<br />
[[Wikipedia:ls|ls]] lists directory contents.<br />
<br />
See {{ic|info ls}} or [http://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html#ls-invocation the online manual] for more information.<br />
<br />
=== Long format ===<br />
<br />
The {{ic|-l}} option displays some metadata, for example:<br />
<br />
{{hc|$ ls -l /path/to/directory|<br />
total 128<br />
drwxr-xr-x 2 archie users 4096 Jul 5 21:03 Desktop<br />
drwxr-xr-x 6 archie users 4096 Jul 5 17:37 Documents<br />
drwxr-xr-x 2 archie users 4096 Jul 5 13:45 Downloads<br />
-rw-rw-r-- 1 archie users 5120 Jun 27 08:28 customers.ods<br />
-rw-r--r-- 1 archie users 3339 Jun 27 08:28 todo<br />
-rwxr-xr-x 1 archie users 2048 Jul 6 12:56 myscript.sh<br />
}}<br />
<br />
The {{ic|total}} value represents the total disk allocation for the files in the directory, by default in number of blocks.<br />
<br />
Below, each file and subdirectory is represented by a line divided into 7 metadata fields, in the following order:<br />
<br />
* type and permissions:<br />
** the first character is the entry type, see {{ic|info ls -n "What information is listed"}} for an explanation of all the possible types; for example:<br />
*** {{ic|-}} denotes a normal file;<br />
*** {{ic|d}} denotes a directory, i.e. a folder containing other files or folders;<br />
*** {{ic|p}} denotes a named pipe (aka FIFO);<br />
*** {{ic|l}} denotes a symbolic link;<br />
** the remaining characters are the entry's [[permissions]];<br />
* number of [[Wikipedia:Hard link|hard links]] for the entity; files will have at least 1, i.e. the showed reference itself; folders will have at least 2: the showed reference, the self-referencing {{ic|.}} entry, and then a {{ic|..}} entry in each of its subfolders;<br />
* owner [[user]] name;<br />
* [[group]] name;<br />
* size;<br />
* last modification timestamp;<br />
* entity name.<br />
<br />
=== File names containing spaces enclosed in quotes ===<br />
<br />
By default, file and directory names that contain spaces are displayed surrounded by single quotes. To change this behavior use the {{ic|-N}} or {{ic|1=--quoting-style=literal}} options. Alternatively, set the {{ic|QUOTING_STYLE}} [[environment variable]] to {{ic|literal}}. [https://unix.stackexchange.com/questions/258679/why-is-ls-suddenly-surrounding-items-with-spaces-in-single-quotes]<br />
<br />
== lsblk ==<br />
<br />
{{man|8|lsblk}} will show all available [[w:Device_file#Block_devices|block devices]] along with their partitioning schemes, for example:<br />
<br />
{{hc|$ lsblk -f|<br />
NAME FSTYPE LABEL UUID MOUNTPOINT<br />
sda<br />
├─sda1 vfat C4DA-2C4D /boot<br />
├─sda2 swap 5b1564b2-2e2c-452c-bcfa-d1f572ae99f2 [SWAP]<br />
└─sda3 ext4 56adc99b-a61e-46af-aab7-a6d07e504652 /<br />
}}<br />
<br />
The beginning of the device name specifies the type of block device. Most modern storage devices (e.g. hard disks, [[SSD]]s and USB flash drives) are recognised as SCSI disks ({{ic|sd}}). The type is followed by a lower-case letter starting from {{ic|a}} for the first device ({{ic|sda}}), {{ic|b}} for the second device ({{ic|sdb}}), and so on. ''Existing'' partitions on each device will be listed with a number starting from {{ic|1}} for the first partition ({{ic|sda1}}), {{ic|2}} for the second ({{ic|sda2}}), and so on. In the example above, only one device is available ({{ic|sda}}), and that device has three partitions ({{ic|sda1}} to {{ic|sda3}}), each with a different [[file system]].<br />
<br />
Other common block device types include for example {{ic|mmcblk}} for memory cards and {{ic|nvme}} for [[Solid_State_Drives/NVMe|NVMe]] devices. Unknown types can be searched in the [https://www.kernel.org/doc/Documentation/devices.txt kernel documentation].<br />
<br />
== mkdir ==<br />
<br />
[[Wikipedia:mkdir|mkdir]] makes directories.<br />
<br />
To create a directory and its whole hierarchy, the {{ic|-p}} switch is used, otherwise an error is printed. As users are supposed to know what they want, {{ic|-p}} switch may be used as a default:<br />
<br />
alias mkdir='mkdir -p -v'<br />
<br />
The {{ic|-v}} switch make it verbose.<br />
<br />
Changing mode of a just created directory using ''chmod'' is not necessary as the {{ic|-m}} option lets you define the access permissions.<br />
<br />
{{Tip|If you just want a temporary directory, a better alternative may be [[Wikipedia:Temporary file|mktemp]]: {{ic|mktemp -p}}.}}<br />
<br />
== mv ==<br />
<br />
[[Wikipedia:mv|mv]] moves and renames files and directories.<br />
<br />
To limit potential damage caused by the command, use an alias:<br />
<br />
alias mv='timeout 8 mv -iv'<br />
<br />
This alias suspends ''mv'' after eight seconds, asks for confirmation before overwriting any existing files, lists the operations in progress and does not store itself in the shell history file if the shell is configured to ignore space starting commands.<br />
<br />
== od ==<br />
<br />
The [[Wikipedia:od (Unix)|od]] (''o''ctal ''d''ump) command is useful for visualizing data that is not in a human-readable format, like the executable code of a program, or the contents of an unformatted device. See the [http://www.gnu.org/software/coreutils/manual/html_node/od-invocation.html#od-invocation manual] for more information.<br />
<br />
== pv ==<br />
<br />
You can use {{Pkg|pv}} (''pipe viewer'') to monitor the progress of data through a pipeline, for example:<br />
<br />
# dd if=''/source/filestream'' | pv -''monitor_options'' -s ''size_of_file'' | dd of=''/destination/filestream''<br />
<br />
In most cases {{ic|pv}} functions as a drop-in replacement for {{ic|cat}}.<br />
<br />
== rm ==<br />
<br />
[[Wikipedia:rm_(Unix)|rm]] removes files or directories.<br />
<br />
To limit potential damage caused by the command, use an alias:<br />
<br />
alias rm='timeout 3 rm -Iv --one-file-system'<br />
<br />
This alias suspends ''rm'' after three seconds, asks confirmation to delete three or more files, lists the operations in progress, does not involve more than one file systems and does not store itself in the shell history file if the shell is configured to ignore space starting commands. Substitute {{ic|-I}} with {{ic|-i}} if you prefer to confirm even for one file.<br />
<br />
Zsh users may want to put {{ic|noglob}} before {{ic|timeout}} to avoid implicit expansions.<br />
<br />
To remove directories known to be empty, use ''rmdir'' as it fails in case of files inside the target.<br />
<br />
== sed ==<br />
<br />
[[Wikipedia:sed|sed]] is stream editor for filtering and transforming text.<br />
<br />
Here is a handy [http://sed.sourceforge.net/sed1line.txt list] of ''sed'' one-liners examples.<br />
<br />
{{Tip|More powerful alternatives are [[Wikipedia:AWK|AWK]] and even [[Wikipedia:Perl|Perl]] language.}}<br />
<br />
== seq ==<br />
<br />
''seq'' prints a sequence of numbers. Shell built-in alternatives are available, so it is good practice to use them as explained on [[Wikipedia:Seq (Unix)|Wikipedia]].<br />
<br />
== ss ==<br />
<br />
''ss'' is a utility to investigate network ports and is part of the {{Pkg|iproute2}} package in the {{Grp|base}} group. It has a similar functionality to the [https://www.archlinux.org/news/deprecation-of-net-tools/ deprecated] netstat utility. <br />
<br />
Common usage includes:<br />
<br />
Display all TCP Sockets with service names:<br />
$ ss -at<br />
<br />
Display all TCP Sockets with port numbers:<br />
$ ss -atn<br />
<br />
Display all UDP Sockets:<br />
$ ss -au<br />
<br />
For more information see {{man|8|ss}} or [http://www.cyberciti.biz/files/ss.html introductory examples].<br />
<br />
== tar ==<br />
<br />
As an early Unix archiving format, .tar files—known as "tarballs"—are widely used for packaging in Unix-like operating systems. Both [[pacman]] and [[AUR]] packages are compressed tarballs, and Arch uses [[GNU Project|GNU's]] ''tar'' program by default. <br />
<br />
For .tar archives, ''tar'' by default will extract the file according to its extension:<br />
<br />
$ tar xvf ''file.EXTENSION''<br />
<br />
Forcing a given format:<br />
<br />
{| class="wikitable"<br />
!File Type !! Extraction Command<br />
|-<br />
|{{ic|''file''.tar}} || {{Ic|tar xvf ''file''.tar}}<br />
|-<br />
|{{ic|''file''.tgz}} || {{Ic|tar xvzf ''file''.tgz}}<br />
|-<br />
|{{ic|''file''.tar.gz}} || {{Ic|tar xvzf ''file''.tar.gz}}<br />
|-<br />
|{{ic|''file''.tar.bz}} || {{Ic|bzip -cd ''file''.bz <nowiki>|</nowiki> tar xvf -}}<br />
|-<br />
|{{ic|''file''.tar.bz2}} || {{Ic|tar xvjf ''file''.tar.bz2}}<br> {{Ic|bzip2 -cd ''file''.bz2 <nowiki>| tar xvf -</nowiki>}}<br />
|-<br />
|{{ic|''file''.tar.xz}} || {{Ic|tar xvJf ''file''.tar.xz}}<br> {{Ic|xz -cd ''file''.xz <nowiki>| tar xvf -</nowiki>}}<br />
|}<br />
<br />
The construction of some of these ''tar'' arguments may be considered legacy, but they are still useful when performing specific operations. See its [[man page]] with {{ic|man tar}} for details.<br />
<br />
== which ==<br />
<br />
[[wikipedia:Which_(Unix)|which]] shows the full path of shell commands. In the following example the full path of {{ic|ssh}} is used as an argument for {{ic|journalctl}}:<br />
<br />
# journalctl $(which sshd)<br />
<br />
== wipefs ==<br />
<br />
''wipefs'' can list or erase [[file system]], [[RAID]] or [[partition|partition-table]] signatures (magic strings) from the specified device. It does not erase the file systems themselves nor any other data from the device.<br />
<br />
See {{man|8|wipefs}} for more information.<br />
<br />
For example, to erase all signatures from the device {{ic|/dev/sdb}} and create a signature backup {{ic|~/wipefs-sdb-''offset''.bak}} file for each signature:<br />
<br />
# wipefs --all --backup /dev/sdb<br />
<br />
== See also ==<br />
<br />
* [http://www.reddit.com/r/commandline/comments/19garq/a_sampling_of_coreutils_120/ A sampling of coreutils] [http://www.reddit.com/r/commandline/comments/19ge6v/a_sampling_of_coreutils_2040/ , part 2] [http://www.reddit.com/r/commandline/comments/19j1w3/a_sampling_of_coreutils_4060/ , part 3] - Overview of commands in coreutils<br />
* [http://www.gnu.org/software/coreutils/manual/coreutils.html GNU Coreutils online documentation]<br />
* [http://www.linuxquestions.org/questions/linux-newbie-8/learn-the-dd-command-362506/ Learn the DD command]</div>Chariblaze