Sunday, November 5, 2017

APT (Debian)

The Advanced Package Tool, or APT, is a free software user interface that works with core libraries to handle the installation and removal of software on the Debian, Slackware and other Linux distributions.[3] APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, either from precompiled files or by compiling source code.[3]
APT was originally designed as a front-end for dpkg to work with Debian's .deb packages, but it has since been modified to also work with the RPM Package Manager system via APT-RPM.[4] The Fink project has ported APT to Mac OS X for some of its own package management tasks,[5] and APT is also available in OpenSolaris.

Contents

Usage

There has been an apt program since version 1.0; apt is a collection of tools distributed in a package named apt. A significant part of apt is defined in a C++ library of functions; apt also includes command-line programs for dealing with packages, which use the library. Three such programs are apt, apt-get and apt-cache. They are commonly used in examples of apt because they are simple and ubiquitous. The apt package is of "important" priority in all current Debian releases, and is therefore installed in a default Debian installation. Apt can be considered a front-end to dpkg, friendlier than the older dselect front-end. While dpkg performs actions on individual packages, apt tools manage relations (especially dependencies) between them, as well as sourcing and management of higher-level versioning decisions (release tracking and version pinning).
APT is often hailed as one of Debian's best features,[6][7][8][9] which Debian developers attribute to the strict quality controls in Debian's policy.[10][11]
A major feature in APT is the way it calls dpkg — it does topological sorting of the list of packages to be installed or removed and calls dpkg in the best possible sequence. In some cases, it utilizes the --force options in dpkg. However, it only does this when it is unable to calculate how to avoid the reason dpkg requires the action to be forced.

Installing software

The user indicates one or more packages to be installed. Each package name is phrased as just the name portion of the package, not a fully qualified filename (for instance, in a Debian system, libc6 would be the argument provided, not libc6_1.9.6-2.deb). Notably, apt automatically gets and installs packages upon which the indicated package depends (if necessary). This was an original distinguishing characteristic of apt-based package management systems, as it avoided installation failure due to missing dependencies, a type of dependency hell.
Another such distinction is remote repository retrieval of packages. apt uses location configuration file (/etc/apt/sources.list) to locate the desired packages, which might be available on the network or a removable storage medium, for example, and retrieve them, and also obtain information about available (but not installed) packages.
apt provides other command options to override decisions made by apt-get's conflict resolution system. One option is to force a particular version of a package. This can downgrade a package and render dependent software inoperable, so the user must be careful.
Finally, the apt_preferences mechanism allows the user to create an alternative installation policy for individual packages.
The user can specify packages by POSIX regular expression.

apt-get

apt-get is the command line package management tool supplied with the Debian package apt. APT searches its cached list of packages and lists the dependencies that must be installed or updated.
Triggers are the treatment of deferred actions.
APT retrieves, configures and installs the dependencies automatically.

Update, upgrade and dist-upgrade

Other commands used in apt-get:
  • update is used to resynchronize the package index files from their sources. The lists of available packages are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available.
  • upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version.
  • dist-upgrade, in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files.[12] aptitude has a smarter dist-upgrade feature called full-upgrade.[13]

apt-file

apt-file is a command to find which package includes a specific file, or to list all files included in a package. It is packaged separately from the main APT utilities.
Example to find a package:
$ apt-file update         # Fetch the files installed by the packages in local cache

$ apt-file find vmlinuz   # Find all packages providing a filename vmlinuz
linux-image-4.8.0-17-generic: /boot/vmlinuz-4.8.0-17-generic
linux-image-4.8.0-17-lowlatency: /boot/vmlinuz-4.8.0-17-lowlatency
linux-image-4.8.0-19-generic: /boot/vmlinuz-4.8.0-19-generic
linux-image-4.8.0-19-lowlatency: /boot/vmlinuz-4.8.0-19-lowlatency
linux-signed-image-4.8.0-17-generic: /usr/lib/linux/vmlinuz-4.8.0-17-generic.efi.signature
linux-signed-image-4.8.0-17-lowlatency: /usr/lib/linux/vmlinuz-4.8.0-17-lowlatency.efi.signature
linux-signed-image-4.8.0-19-generic: /usr/lib/linux/vmlinuz-4.8.0-19-generic.efi.signature
linux-signed-image-4.8.0-19-lowlatency: /usr/lib/linux/vmlinuz-4.8.0-19-lowlatency.efi.signature
ltsp-client-core: /usr/share/ltsp/cleanup.d/50-vmlinuz
needrestart: /usr/lib/needrestart/vmlinuz-get-version

$ apt-file find /boot/vmlinuz-4.8.0-17-generic  # Find also from a full path
linux-image-4.8.0-17-generic: /boot/vmlinuz-4.8.0-17-generic

$ dpkg -S vmlinuz                               # dpkg is an alternative listing less packages
linux-image-4.8.0-16-generic: /boot/vmlinuz-4.8.0-16-generic
linux-image-4.8.0-17-generic: /boot/vmlinuz-4.8.0-17-generic
linux-image-4.8.0-11-generic: /boot/vmlinuz-4.8.0-11-generic
linux-image-4.4.0-9136-generic: /boot/vmlinuz-4.4.0-9136-generic
linux-image-4.8.0-19-generic: /boot/vmlinuz-4.8.0-19-generic

Configuration and files

/etc/apt has the apt configuration folders and files.
apt-config is the APT Configuration Query program.[14] apt-config dump shows the configuration.[15]

Files

  • /etc/apt/sources.list: Locations to fetch packages from.
  • /etc/apt/sources.list.d/: Additional source list fragments.
  • /etc/apt/apt.conf: APT configuration file.
  • /etc/apt/apt.conf.d/: APT configuration file fragments.
  • /etc/apt/preferences: version preferences file. This is where you would specify "pinning", i.e. a preference to get certain packages from a separate source or from a different version of a distribution.
  • /var/cache/apt/archives/: storage area for retrieved package files.
  • /var/cache/apt/archives/partial/: storage area for package files in transit.
  • /var/lib/apt/lists/: storage area for state information for each package resource specified in sources.list
  • /var/lib/apt/lists/partial/: storage area for state information in transit.

Sources

APT relies on the concept of repositories in order to find software and resolve dependencies. For apt, a repository is a directory containing packages along with an index file. This can be specified as a networked or CDROM location. The Debian project keeps a central repository of over 25,000 software packages ready for download and installation.
Any number of additional repositories can be added to APT's sources.list configuration file (/etc/apt/sources.list) and then be queried by APT. Graphical front-ends often allow modifying sources.list more simply (apt-setup). Once a package repository has been specified (like during the system installation), packages in that repository can be installed without specifying a source and will be kept up-to-date automatically.
In addition to network repositories, compact discs and other storage media (USB keydrive, hard disks...) can be used as well, using apt-cdrom[16] or adding file:/[17] to the source list file. Apt-cdrom can specify a different folder than a cd-rom, using the -d option (i.e. a hard disk or a USB keydrive). The Debian CDs available for download contain Debian repositories. This allows non-networked machines to be upgraded. Also one can use apt-zip.
Problems may appear when several sources offer the same package(s). Systems that have such possibly conflicting sources can use APT pinning to control which sources should be preferred.

APT pinning

The APT pinning feature allows administrators to force APT to choose particular versions of packages which may be available in different versions from different repositories. This allows administrators to ensure that packages are not upgraded to versions which may conflict with other packages on the system, or that have not been sufficiently tested for unwelcome changes.
In order to do this, the pins in APT's preferences file (/etc/apt/preferences) must be modified,[18] although graphical front-ends often make pinning simpler.

Front-ends

Synaptic Package Manager is one of the front-ends available for APT
Several other front-ends to APT exist, which provide more advanced installation functions and more intuitive interfaces. These include:
APT front-ends can:
  • Search for new packages.
  • Upgrade packages.
  • Install or remove packages.
  • Upgrade the whole system to a new release.
APT front-ends can list the dependencies of packages being installed or upgraded, ask the administrator if packages recommended or suggested by newly installed packages should be installed too, automatically install dependencies and perform other operations on the system such as removing obsolete files and packages.

History

The original effort that led to the apt-get program was the dselect replacement project known by its codename deity.[24] This project was commissioned by Brian White, the Debian Release Manager at the time. The very first functional version of apt-get was called dpkg-get and was only intended to be a test program for the core library functions that would underpin the new UI.[25]
Much of the original development of APT was done on IRC, so records have been lost. The 'Deity Creation Team' mailing list archives include only the major highlights.
The Deity name was abandoned as the official name for the project due to concerns over the religious nature of the name. The APT name was eventually decided after considerable internal and public discussion. Ultimately the name was proposed on IRC, accepted and then finalized on the mailing lists.[26]
APT was introduced in 1998 and original test builds were circulated on IRC. The first Debian version that included it was Debian 2.1, released on 9 March 1999.[27]
In the end the original goal of the Deity project of replacing the dselect user interface (UI) was a failure. Work on the UI portion of the project was abandoned (the UI directories were removed from the CVS system) after the first public release of apt-get. The response to APT as a dselect method and a command line utility was so great and positive that all development efforts focused on maintaining and improving the tool. It was not until much later that several independent people built UIs on top of libapt-pkg.
Eventually, a new team picked up the project, began to build new features and released version 0.6 of APT which introduced the Secure APT feature, using strong cryptographic signing to authenticate the package repositories.[28]

dpkg

dpkg is the software at the base of the package management system in the free operating system Debian and its numerous derivatives. dpkg is used to install, remove, and provide information about .deb packages.
dpkg (Debian Package) itself is a low level tool. APT (Advanced Packaging Tool), a higher level tool, is more commonly used than dpkg as it can fetch packages from remote locations and deal with complex package relations, such as dependency resolution. Frontends for APT like aptitude (ncurses) and synaptic (GTK+) are used for their friendlier interfaces.
The Debian package "dpkg" provides the dpkg program, as well as several other programs necessary for run-time functioning of the packaging system, including dpkg-deb, dpkg-split, dpkg-query, dpkg-statoverride, dpkg-divert and dpkg-trigger.[5] It also includes the programs such as update-alternatives and start-stop-daemon. The install-info program used to be included as well, but was later removed[6] as it is now developed and distributed separately.[7] The Debian package "dpkg-dev" includes the numerous build tools described below.

Contents

History

dpkg was originally created by Ian Murdock in January of 1994 as a Shell script,[1] Matt Welsh, Carl Streeter and Ian Murdock then rewrote it in Perl,[8] and then later the main part was rewritten in C by Ian Jackson in 1994.[9][10] The name dpkg was originally the short for "Debian package", but the meaning of that phrase has evolved significantly, as dpkg the software is orthogonal to the deb package format as well as the Debian Policy Manual which defines how Debian packages behave in Debian.

Example use

To install a .deb package:
dpkg -i filename.deb
where filename.deb is the name of the Debian package (such as pkgname_0.00-1_amd64.deb).
The list of installed packages can be obtained with:
dpkg -l [optional pattern]
To remove an installed package:
dpkg -r packagename

Development tools

dpkg-dev contains a series of development tools required to unpack, build and upload Debian source packages.[11] These include:
  • dpkg-source packs and unpacks the source files of a Debian package.
  • dpkg-gencontrol reads the information from an unpacked Debian tree source and generates a binary package control package, creating an entry for this in Debian/files.
  • dpkg-shlibdeps calculates the dependencies of runs with respect to libraries.
  • dpkg-genchanges reads the information from an unpacked Debian tree source that once constructed creates a control file (.changes).
  • dpkg-buildpackage is a control script that can be used to construct the package automatically.
  • dpkg-distaddfile adds a file input to debian/files.
  • dpkg-parsechangelog reads the changes file (changelog) of an unpacked Debian tree source and creates a conveniently prepared output with the information for those changes.

Database

The dpkg database is located under /var/lib/dpkg; the "status" file contains the list of installed software on the current system. There is no information about repositories in this database.[12]

Thursday, October 12, 2017

How to Find Files and Folders in Linux Using the Command Line

Most people use a graphical file manager to find files in Linux, such as Nautilus in Gnome, Dolphin in KDE, and Thunar in Xfce. However, there are several ways to use the command line to find files in Linux, no matter what desktop manager you use.
01_search_in_nautilus

Using the Find Command

The “find” command allows you to search for files for which you know the approximate filenames. The simplest form of the command searches for files in the current directory and recursively through its subdirectories that match the supplied search criteria. You can search for files by name, owner, group, type, permissions, date, and other criteria.
Typing the following command at the prompt lists all files found in the current directory.
find .
The dot after “find” indicates the current directory.
02_find_dot_command
To find files that match a specific pattern, use the -name argument. You can use filename metacharacters (such as * ), but you should either put an escape character ( \ ) in front of each of them or enclose them in quotes.
For example, if we want to find all the files that start with “pro” in the Documents directory, we would use the cd Documents/ command to change to the Documents directory, and then type the following command:
find . -name pro\*
All files in the current directory starting with “pro” are listed.
NOTE: The find command defaults to being case sensitive. If you want the search for a word or phrase to be case insensitive, use the -iname option with the find command. It is the case insensitive version of the -name command.
03_find_using_name_argument
If find doesn’t locate any files matching your criteria, it produces no output.
The find command has a lot of options available for refining the search. For more information about the find command, run man find  in a Terminal window and press Enter.

Using the Locate Command

The locate command is faster than the find command because it uses a previously built database, whereas the find command searches in the real system, through all the actual directories and files. The locate command returns a list of all path names containing the specified group of characters.
The database is updated periodically from cron, but you can also update it yourself at any time so you can obtain up-to-the-minute results. To do this, type the following command at the prompt:
sudo updatedb
Enter your password when prompted.
04_updating_locate_database
The basic form of the locate command finds all the files on the file system, starting at the root, that contain all or any part of the search criteria.
locate mydata
For example, the above command found two files containing “mydata” and one file containing “data.”
05_using_basic_locate_command
If you want to find all files or directories that contain exactly and only your search criteria, use the -b option with the locate command, as follows.
locate -b ‘\mydata’
The backslash in the above command is a globbing character, which provides a way of expanding wildcard characters in a non-specific file name into a set of specific filenames. A wildcard is a symbol that can be replaced by one or more characters when the expression is evaluated. The most common wildcard symbols are the question mark ( ? ), which stands for a single character and the asterisk ( * ), which stands for a contiguous string of characters. In the above example, the backslash disables the implicit replacement of “mydata” by “*mydata*” so you end up with only results containing “mydata.”
06_locate_with_b_option
The mlocate command is a new implementation of locate. It indexes the entire file system, but the search results only include files to which the current user has access. When you update the mlocate database, it keeps timestamp information in the database. This allows mlocate to know if the contents of a directory changed without reading the contents again and makes updates to the database faster and less demanding on your hard drive.
When you install mlocate, the /usr/bin/locate binary file changes to point to mlocate. To install mlocate, if it’s not already included in your Linux distribution, type the following command at the prompt.
sudo apt-get install mlocate
NOTE: We will show you a command later in this article that allows you to determine where the executable for a command is located, if it exists.
07_installing_mlocate
The mlocate command does not use the same database file as the standard locate command. Therefore, you may want to create the database manually by typing the following command at the prompt:
sudo /etc/cron.daily/mlocate
The mlocate command will not work until the database is created either manually or when the script is run from cron.
08_creating_the_database
For more information about either the locate or the mlocate command, type man locate or man mlocate  in a Terminal window and press Enter. The same help screen displays for both commands.

Using the Which Command

The “which” command returns the absolute path of the executable that is called when a command is issued. This is useful in finding the location of an executable for creating a shortcut to the program on the desktop, on a panel, or other place in the desktop manager. For example, typing the command which firefox displays the results shown in the image below.
09_using_which_command
By default, the which command only displays the first matching executable. To display all matching executables, use the -a option with the command:
which -a firefox
You can search for multiple executables using at once, as shown in the following image. Only the paths to executables found are displayed. In the example below, only the “ps” executable was found.
10_using_which_command_multiple_programs
NOTE: The which command only searches the current user’s PATH variable. If you search for an executable that is only available for the root user as a normal user, no results will display.
For more information about the which command, type “man which” (without the quotes) at the command prompt in a Terminal window and press Enter.

Using the Whereis Command

The whereis command is used to find out where the binary, source, and man page files for a command are located. For example, typing whereis firefox at the prompt displays results as shown in the following image.
11_using_whereis_command
If you want only the path to the executable to display, and not the paths to the source and the man(ual) pages, use the -b option. For example, the command whereis -b firefox will display only /usr/bin/firefox as the result. This is handy because you will most likely search for a program’s executable file more often than you would search for source and man pages for that program. You can also search for only the source files ( -s ) or for only the man pages ( -m ).
For more information about the whereis command, type man whereis in a Terminal window and press Enter.

Understanding the Difference Between the Whereis Command and the Which Command

The whereis command shows you the location for the binary, source, and man pages for a command, whereas the which command only shows you the location of the binary for the command.
The whereis command searches through a list of specific directories for the binary, source, and man files whereas the which command searches the directories listed in the current user’s PATH environment variable. For the whereis command, the list of specific directories can be found in the FILES section of the man pages for the command.
When it comes to results displayed by default, the whereis command displays everything it finds whereas the which command only displays the first executable it finds. You can change that using the -a option, discussed earlier, for the which command.
Because the whereis command only uses paths hard-coded into the command, you may not always find what you are looking for. If you are searching for a program you think might be installed in a directory not listed in the man pages for the whereis command, you might want to use the which command with the -a option to find all occurrences of the command throughout the system.

Tuesday, October 10, 2017

10 Useful Commands to Collect System and Hardware Information in Linux

It is always a good practice to know the hardware components of your Linux system is running on, this helps you to deal with compatibility issues when it comes to installing packages, drivers on your system.
Check Hardware and System Information in Linux
10 Commands to Check Hardware and System Information in Linux
Therefore in this tips and tricks, we shall look at some useful commands that can help you to extract information about your Linux system and hardware components.

1. How to View Linux System Information

To know only system name, you can use uname command without any switch will print system information or uname -s command will print the kernel name of your system.
tecmint@tecmint ~ $ uname
Linux
To view your network hostname, use ‘-n’ switch with uname command as shown.
tecmint@tecmint ~ $ uname -n
tecmint.com
To get information about kernel-version, use ‘-v’ switch.
tecmint@tecmint ~ $ uname -v
#64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014
To get the information about your kernel release, use ‘-r’ switch.
tecmint@tecmint ~ $ uname -r
3.13.0-37-generic
To print your machine hardware name, use ‘-m’ switch:
tecmint@tecmint ~ $ uname -m
x86_64
All this information can be printed at once by running ‘uname -a’ command as shown below.
tecmint@tecmint ~ $ uname -a
Linux tecmint.com 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

2. How to View Linux System Hardware Information

Here you can use the lshw tool to gather vast information about your hardware components such as cpu, disks, memory, usb controllers etc.
lshw is a relatively small tool and there are few options that you can use with it while extracting information. The information provided by lshw gathered form different /proc files.
Note: Do remember that the lshw command executed by superuser (root) or sudo user.
Read Also: Difference Between su and sudo User in Linux
To print information about your Linux system hardware, run this command.
tecmint@tecmint ~ $ sudo lshw
tecmint.com               
description: Notebook
product: 20354 (LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70)
vendor: LENOVO
version: Lenovo Z50-70
serial: 1037407803441
width: 64 bits
capabilities: smbios-2.7 dmi-2.7 vsyscall32
configuration: administrator_password=disabled boot=normal chassis=notebook family=IDEAPAD frontpanel_password=disabled keyboard_password=disabled power-on_password=disabled sku=LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70 uuid=E4B1D229-D237-E411-9F6E-28D244EBBD98
*-core
description: Motherboard
product: Lancer 5A5
vendor: LENOVO
physical id: 0
version: 31900059WIN
serial: YB06377069
slot: Type2 - Board Chassis Location
*-firmware
description: BIOS
vendor: LENOVO
physical id: 0
version: 9BCN26WW
date: 07/31/2014
size: 128KiB
capacity: 4032KiB
capabilities: pci upgrade shadowing cdboot bootselect edd int13floppynec int13floppytoshiba int13floppy360 int13floppy1200 int13floppy720 int13floppy2880 int9keyboard int10video acpi usb biosbootspecification uefi
......
You can print a summary of your hardware information by using the -short option.
tecmint@tecmint ~ $ sudo lshw -short
H/W path       Device      Class          Description
=====================================================
system         20354 (LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70)
/0                         bus            Lancer 5A5
/0/0                       memory         128KiB BIOS
/0/4                       processor      Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
/0/4/b                     memory         32KiB L1 cache
/0/4/c                     memory         256KiB L2 cache
/0/4/d                     memory         3MiB L3 cache
/0/a                       memory         32KiB L1 cache
/0/12                      memory         8GiB System Memory
/0/12/0                    memory         DIMM [empty]
/0/12/1                    memory         DIMM [empty]
/0/12/2                    memory         8GiB SODIMM DDR3 Synchronous 1600 MHz (0.6 ns)
/0/12/3                    memory         DIMM [empty]
/0/100                     bridge         Haswell-ULT DRAM Controller
/0/100/2                   display        Haswell-ULT Integrated Graphics Controller
/0/100/3                   multimedia     Haswell-ULT HD Audio Controller
...
If you wish to generate output as a html file, you can use the option -html.
tecmint@tecmint ~ $ sudo lshw -html > lshw.html
Generate Linux Hardware Information in HTML
Generate Linux Hardware Information in HTML

3. How to View Linux CPU Information

To view information about your CPU, use the lscpu command as it shows information about your CPU architecture such as number of CPU’s, cores, CPU family model, CPU caches, threads, etc from sysfs and /proc/cpuinfo.
tecmint@tecmint ~ $ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 69
Stepping:              1
CPU MHz:               768.000
BogoMIPS:              4788.72
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0-3

4. How to Collect Linux Block Device Information

Block devices are storage devices such as hard disks, flash drives etc. lsblk command is used to report information about block devices as follows.
tecmint@tecmint ~ $ lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda       8:0    0 931.5G  0 disk 
├─sda1    8:1    0  1000M  0 part 
├─sda2    8:2    0   260M  0 part /boot/efi
├─sda3    8:3    0  1000M  0 part 
├─sda4    8:4    0   128M  0 part 
├─sda5    8:5    0 557.1G  0 part 
├─sda6    8:6    0    25G  0 part 
├─sda7    8:7    0  14.7G  0 part 
├─sda8    8:8    0     1M  0 part 
├─sda9    8:9    0 324.5G  0 part /
└─sda10   8:10   0   7.9G  0 part [SWAP]
sr0      11:0    1  1024M  0 rom  
If you want to view all block devices on your system then include the -a option.
tecmint@tecmint ~ $ lsblk -a
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda       8:0    0 931.5G  0 disk 
├─sda1    8:1    0  1000M  0 part 
├─sda2    8:2    0   260M  0 part /boot/efi
├─sda3    8:3    0  1000M  0 part 
├─sda4    8:4    0   128M  0 part 
├─sda5    8:5    0 557.1G  0 part 
├─sda6    8:6    0    25G  0 part 
├─sda7    8:7    0  14.7G  0 part 
├─sda8    8:8    0     1M  0 part 
├─sda9    8:9    0 324.5G  0 part /
└─sda10   8:10   0   7.9G  0 part [SWAP]
sdb       8:16   1         0 disk 
sr0      11:0    1  1024M  0 rom  
ram0      1:0    0    64M  0 disk 
ram1      1:1    0    64M  0 disk 
ram2      1:2    0    64M  0 disk 
ram3      1:3    0    64M  0 disk 
ram4      1:4    0    64M  0 disk 
ram5      1:5    0    64M  0 disk 
ram6      1:6    0    64M  0 disk 
ram7      1:7    0    64M  0 disk 
ram8      1:8    0    64M  0 disk 
ram9      1:9    0    64M  0 disk 
loop0     7:0    0         0 loop 
loop1     7:1    0         0 loop 
loop2     7:2    0         0 loop 
loop3     7:3    0         0 loop 
loop4     7:4    0         0 loop 
loop5     7:5    0         0 loop 
loop6     7:6    0         0 loop 
loop7     7:7    0         0 loop 
ram10     1:10   0    64M  0 disk 
ram11     1:11   0    64M  0 disk 
ram12     1:12   0    64M  0 disk 
ram13     1:13   0    64M  0 disk 
ram14     1:14   0    64M  0 disk 
ram15     1:15   0    64M  0 disk 

5. How to Print USB Controllers Information

The lsusb command is used to report information about USB controllers and all the devices that are connected to them.
tecmint@tecmint ~ $ lsusb
Bus 001 Device 002: ID 8087:8000 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 005: ID 0bda:b728 Realtek Semiconductor Corp. 
Bus 002 Device 004: ID 5986:0249 Acer, Inc 
Bus 002 Device 003: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 002 Device 002: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
You can use the -v option to generate a detailed information about each USB device.
tecmint@tecmint ~ $ lsusb -v

6. How to Print PCI Devices Information

PCI devices may included usb ports, graphics cards, network adapters etc. The lspci tool is used to generate information concerning all PCI controllers on your system plus the devices that are connected to them.
To print information about PCI devices run the following command.
tecmint@tecmint ~ $ lspci
00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 0b)
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b)
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 0b)
00:14.0 USB controller: Intel Corporation Lynx Point-LP USB xHCI HC (rev 04)
00:16.0 Communication controller: Intel Corporation Lynx Point-LP HECI #0 (rev 04)
00:1b.0 Audio device: Intel Corporation Lynx Point-LP HD Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 3 (rev e4)
00:1c.3 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 4 (rev e4)
00:1c.4 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 5 (rev e4)
00:1d.0 USB controller: Intel Corporation Lynx Point-LP USB EHCI #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Lynx Point-LP LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation Lynx Point-LP SATA Controller 1 [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation Lynx Point-LP SMBus Controller (rev 04)
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 10)
02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8723BE PCIe Wireless Network Adapter
03:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 840M] (rev a2)
Use the -t option to produce output in a tree format.
tecmint@tecmint ~ $ lspci -t
-[0000:00]-+-00.0
+-02.0
+-03.0
+-14.0
+-16.0
+-1b.0
+-1c.0-[01]----00.0
+-1c.3-[02]----00.0
+-1c.4-[03]----00.0
+-1d.0
+-1f.0
+-1f.2
\-1f.3
Use the -v option to produce detailed information about each connected device.
tecmint@tecmint ~ $ lspci -v
00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 0b)
Subsystem: Lenovo Device 3978
Flags: bus master, fast devsel, latency 0
Capabilities: 
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b) (prog-if 00 [VGA controller])
Subsystem: Lenovo Device 380d
Flags: bus master, fast devsel, latency 0, IRQ 62
Memory at c3000000 (64-bit, non-prefetchable) [size=4M]
Memory at d0000000 (64-bit, prefetchable) [size=256M]
I/O ports at 6000 [size=64]
Expansion ROM at  [disabled]
Capabilities: 
Kernel driver in use: i915
.....

7. How to Print SCSI Devices Information

To view all your scsi/sata devices, use the lsscsi command as follows. If you do not have lsscsi tool installed, run the following command to install it.
$ sudo apt-get install lsscsi        [on Debian derivatives]
# yum install lsscsi                 [On RedHat based systems]
# dnf install lsscsi                 [On Fedora 21+ Onwards]
After install, run the lsscsi command as shown:
tecmint@tecmint ~ $ lsscsi
[0:0:0:0]    disk    ATA      ST1000LM024 HN-M 2BA3  /dev/sda 
[1:0:0:0]    cd/dvd  PLDS     DVD-RW DA8A5SH   RL61  /dev/sr0 
[4:0:0:0]    disk    Generic- xD/SD/M.S.       1.00  /dev/sdb 
Use the -s option to show device sizes.
tecmint@tecmint ~ $ lsscsi -s
[0:0:0:0]    disk    ATA      ST1000LM024 HN-M 2BA3  /dev/sda   1.00TB
[1:0:0:0]    cd/dvd  PLDS     DVD-RW DA8A5SH   RL61  /dev/sr0        -
[4:0:0:0]    disk    Generic- xD/SD/M.S.       1.00  /dev/sdb        -

8. How to Print Information about SATA Devices

You can find some information about sata devices on your system as follows using the hdparm utility. In the example below, I used the block device /dev/sda1 which the harddisk on my system.
tecmint@tecmint ~ $ sudo hdparm /dev/sda1
/dev/sda1:
multcount     =  0 (off)
IO_support    =  1 (32-bit)
readonly      =  0 (off)
readahead     = 256 (on)
geometry      = 56065/255/63, sectors = 2048000, start = 2048
To print information about device geometry interms of cylinders, heads, sectors, size and the starting offset of the device, use the -g option.
tecmint@tecmint ~ $ sudo hdparm -g /dev/sda1
/dev/sda1:
geometry      = 56065/255/63, sectors = 2048000, start = 2048

9. How to Print Linux File System Information

To gather information about file system partitions, you can use fdisk command. Although the main functionality of fdisk command is to modify file system partitions, it can also be used to view information about the different partitions on your file system.
You can print partition information as follows. Remember to run the command as a superuser or else you may not see any output.
tecmint@tecmint ~ $ sudo fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xcee8ad92
Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1  1953525167   976762583+  ee  GPT
Partition 1 does not start on physical sector boundary.

10. How to Extract Information about Hardware Components

You can also use the dmidecode utility to extract hardware information by reading data from the DMI tables.
To print information about memory, run this command as a superuser.
tecmint@tecmint ~ $ sudo dmidecode -t memory
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0005, DMI type 5, 24 bytes
Memory Controller Information
Error Detecting Method: None
Error Correcting Capabilities:
None
Supported Interleave: One-way Interleave
Current Interleave: One-way Interleave
Maximum Memory Module Size: 8192 MB
Maximum Total Memory Size: 32768 MB
Supported Speeds:
Other
Supported Memory Types:
Other
Memory Module Voltage: Unknown
Associated Memory Slots: 4
0x0006
0x0007
0x0008
0x0009
Enabled Error Correcting Capabilities:
None
...
To print information about system, run this command.
tecmint@tecmint ~ $ sudo dmidecode -t system
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0001, DMI type 1, 27 bytes
System Information
Manufacturer: LENOVO
Product Name: 20354
Version: Lenovo Z50-70
Serial Number: 1037407803441
UUID: 29D2B1E4-37D2-11E4-9F6E-28D244EBBD98
Wake-up Type: Power Switch
SKU Number: LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70
Family: IDEAPAD
...
To print information about BIOS, run this command.
tecmint@tecmint ~ $ sudo dmidecode -t bios
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: LENOVO
Version: 9BCN26WW
Release Date: 07/31/2014
Address: 0xE0000
Runtime Size: 128 kB
ROM Size: 4096 kB
Characteristics:
PCI is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
EDD is supported
Japanese floppy for NEC 9800 1.2 MB is supported (int 13h)
Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
5.25"/360 kB floppy services are supported (int 13h)
5.25"/1.2 MB floppy services are supported (int 13h)
3.5"/720 kB floppy services are supported (int 13h)
3.5"/2.88 MB floppy services are supported (int 13h)
8042 keyboard services are supported (int 9h)
CGA/mono video services are supported (int 10h)
ACPI is supported
USB legacy is supported
BIOS boot specification is supported
Targeted content distribution is supported
UEFI is supported
BIOS Revision: 0.26
Firmware Revision: 0.26
...
To print information about processor, run this command.
tecmint@tecmint ~ $ sudo dmidecode -t processor
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0004, DMI type 4, 42 bytes
Processor Information
Socket Designation: U3E1
Type: Central Processor
Family: Core i5
Manufacturer: Intel(R) Corporation
ID: 51 06 04 00 FF FB EB BF
Signature: Type 0, Family 6, Model 69, Stepping 1
Flags:
...

Summary

There are many other ways you can use to obtain information about your system hardware components. Most of these commands use files in the /proc directory to extract system information.
Hope you find this tips and tricks useful and remember to post a comment in case you want to add more information to this or if you face any difficulties in using any of the commands. Remember to always stay connected to Tecmint.

7 Chmod Command Examples for Beginners

Earlier we discussed about how to use octal permission bits with chmod. In this article, let us review how to use symbolic representation with chmod.

Following are the symbolic representation of three different roles:
  • u is for user,
  • g is for group,
  • and o is for others.
Following are the symbolic representation of three different permissions:
  • r is for read permission,
  • w is for write permission,
  • x is for execute permission.
Following are few examples on how to use the symbolic representation on chmod.

1. Add single permission to a file/directory

Changing permission to a single set. + symbol means adding permission. For example, do the following to give execute permission for the user irrespective of anything else:
$ chmod u+x filename

2. Add multiple permission to a file/directory

Use comma to separate the multiple permission sets as shown below.
$ chmod u+r,g+x filename

3. Remove permission from a file/directory

Following example removes read and write permission for the user.
$ chmod u-rx filename

4. Change permission for all roles on a file/directory

Following example assigns execute privilege to user, group and others (basically anybody can execute this file).
$ chmod a+x filename

5. Make permission for a file same as another file (using reference)

If you want to change a file permission same as another file, use the reference option as shown below. In this example, file2’s permission will be set exactly same as file1’s permission.
$ chmod --reference=file1 file2

6. Apply the permission to all the files under a directory recursively

Use option -R to change the permission recursively as shown below.
$ chmod -R 755 directory-name/

7. Change execute permission only on the directories (files are not affected)

On a particular directory if you have multiple sub-directories and files, the following command will assign execute permission only to all the sub-directories in the current directory (not the files in the current directory).
$ chmod u+X *
Note: If the files has execute permission already for either the group or others, the above command will assign the execute permission to the user

Chmod

Check the -R option
chmod -R <permissionsettings> <dirname>
In the future, you can save a lot of time by checking the man page first:
man <command name>
So in this case:
man chmod

Linux cp command

Updated: 04/26/2017 by Computer Hope

Description

The cp command is used to make copies of files and directories.

cp syntax

cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...

cp quick examples

Make a copy of a file into the same directory:
cp origfile newfile
Creates a copy of the file in the working directory named origfile. The copy will be named newfile, and will be located in the working directory.
CAREFUL! If the destination file newfile already exists, it will be overwritten without a confirmation prompt. This is the default behavior for all cp operations.
If you want to be prompted before overwriting a file, use the -i (interactive) option. For example:
cp -i oldfile newfile
If newfile already exists, you will be prompted:
cp: overwrite ‘newfile’?
If you type y (or yes, Y, YES, or any other combination of upper and lowercase of these), then newfile will be overwritten with a copy of origfile. Typing anything else will abort the operation.
Copy a file into another directory:
cp origfile /directory/subdirectory
Creates a copy of the file in the working directory named origfile. The copy will be located in the directory /directory/subdirectory, and will be named origfile.
cp origfile /directory/subdirectory/.
Same as the above command. The slash-dot (/.) is implied in the above form of the command. (The dot is a special file in every Linux directory which means "this directory.")
Copy a file into another directory, and give it a new name:
cp origfile /directory/subdirectory/newfile
Creates a copy of the file in the working directory named origfile. The copy will be named newfile, and will be located in the directory /directory/subdirectory.
Copy multiple files into another directory, using a wildcard:
cp file* /directory/subdirectory
Copy every file in the working directory whose name begins with file into the directory /directory/subdirectory. The asterisk ("*") is a wildcard — a special character which expands to match other characters. Specifically, the asterisk wildcard matches zero or more non-whitespace characters. For instance, this command will copy any files named file, file001, file.txt, fileone.jpg, file-archive.zip, etc.
cp file*.jpg /directory/subdirectory
Copy every file in the working directory whose name begins with file, and ends with the file extension .jpg. For instance, it would make copies of any files named file, file001.jpg, file002.jpg, or file-new.jpg, etc. The copies will be placed into the directory /directory/subdirectory.
Copy an entire directory structure into another location:
cp -R /one/two /three/four
Copy the directory two (located in the directory /one), and everything two contains, into the destination directory /three/four. The result will be called /three/four/two. The directory /three must already exist for the command to succeed. If the directory four does not already exist in the directory /three, it will be created.

General Overview

Let's say you have a file named picture.jpg in your working directory, and you want to make a copy of it called picture-02.jpg. You would run the command:
cp picture.jpg picture-02.jpg
...and the file will be copied. Here, picture.jpg is the source of the copy operation, and picture-02.jpg is the destination. Both files now exist in your working directory.
The source and destination files may also reside in different directories. For instance,
cp /home/chuck/pictures/picture.jpg /home/chuck/backup/picture.jpg
...will make a copy of the file /home/chuck/pictures/picture.jpg in the directory /home/chuck/backup. The destination file will also be named picture.jpg.
If you are the user chuck, you can abbreviate your home directory ("/home/chuck") using a tilde ("~"). For instance,
cp ~/pictures/picture.jpg ~/backup/picture.jpg
...functions the same as the above command when it is run by chuck.
Copying Multiple Files To A Directory
Or, perhaps you want to copy multiple files into another directory. To accomplish this, you can specify multiple files as the source, and a directory name as the destination. Let's say you are the user sally, and you have a bunch of files in the directory /home/sally/pictures/ named picture-01.jpg, picture-02.jpg, etc. and you want to copy them into the directory /home/sally/picture-backup/. This command will do the trick:
cp ~/pictures/picture-*.jpg ~/picture-backup
Here, we use a wildcard (the asterisk, "*") to indicate that the source files are all the files in the directory /home/sally/pictures whose name starts with "picture-" and has the extension ".jpg". They will be copied into the directory /home/sally/picture-backup, assuming that directory already exists. If it doesn't exist, cp will give you an error message, and no files will be copied.
You can also specify multiple source files one after the other, and cp will expect that the final argument is a directory name, and copy them all there. For instance,
cp ~/pictures/picture-01.jpg ~/pictures/picture-02.jpg ~/picture-backup
...will copy only those two files, /home/sally/picture-01.jpg and /home/sally/picture-02.jpg, into the directory /home/sally/picture-backup.
Copying Files Recursively
You can use cp to copy entire directory structures from one place to another using the -R option to perform a recursive copy. Let's say you are the user steve and you have a directory, /home/steve/files, which contains many files and subdirectories. You want to copy all those files, and all the subdirectories (and the files and subdirectories they contain), to a new location, /home/steve/files-backup. You can copy all of them using the command:
cp -R ~/files ~/files-backup
...and the entire directory structure will be copied to the directory /home/steve/files-backup. When performing a recursive copy:
  • If the directory files-backup already exists, the directory files will be placed inside.
  • If files-backup does not already exist, it will be created and the contents of the files directory will be placed inside it.
Creating Symbolic Links Instead Of Copying Data
Another useful trick is to use cp to create symbolic links to your source files. You may already be familiar with using the ln command to create symlinks; cp is a great way to create multiple symlinks all at once.
cp will create symbolic links if you specify the -s option. So, for instance,
cp -s file.txt file2.txt
...will create a symbolic link, file2.txt, which points to file.txt.
You can also create symbolic links from multiple source files, specifying a directory as the destination.
Note: To create symbolic links in another directory, cp needs you to specify the full pathname, including the full directory name, in your source file name(s). Relative paths will not work.
Let's say you are user melissa and you have a set of files, file01.txt, file02.txt, etc. in the directory /home/melissa/myfiles. You want to create symbolic links to these files in the existing directory /home/melissa/myfiles2. This command will do the trick:
cp -s ~/myfiles/file*.txt ~/myfiles2
The directory myfiles2 will now contain symbolic links to the file*.txt in the directory /home/melissa/myfiles. The myfiles2 directory must already exist for the operation to succeed; if it doesn't exist, cp will give you an error message and nothing will be copied.
This will work with a recursive copy, as well. So the command:
cp -R -s ~/myfiles ~/myfiles2
...will re-create the directory structure of /home/melissa/myfiles, including any subdirectories and their contents; any files will be created as symlinks to the originals, but the directories will not be symbolic links, just regular directories. If myfiles2 already exists, cp will create a directory inside it called myfiles which contains the directory structure and symlinks; if myfiles2 does not already exist, it will be created, and contain the subdirectories and symlinks to the files that myfiles contains.
There are many other options you can provide to cp which will affect its behavior. These are listed, along with the precise command syntax, in the following sections.

How to Install and Use the Linux Bash Shell on Windows 10

What You Need to Know About Windows 10’s Bash Shell

This isn’t a virtual machine, a container, or Linux software compiled for Windows (like Cygwin). Instead, Windows 10 gains a Windows Subsystem for Linux, which is based on Microsoft’s abandoned Project Astoria work for running Android apps on Windows.
Think of it as the opposite of Wine. While Wine allows you to run Windows applications directly on Linux, the Windows Subsystem for Linux allows you to run Linux applications directly on Windows.
Microsoft has worked with Canonical to offer a full Ubuntu-based Bash shell that runs atop this subsystem. Technically, this isn’t Linux at all. Linux is the underlying operating system kernel, and that isn’t available here. Instead, this allows you to run the Bash shell and the exact same binaries you’d normally run on Ubuntu Linux. Free-software purists often argue the average Linux operating system  should be called “GNU/Linux” because it’s really a lot of GNU software running on the Linux kernel. The Bash shell you’ll get is really just all those GNU utilities and other software.
There are some limitations here. This won’t work with server software, and it won’t work with graphical software. It’s intended for developers who want to run Linux command-line utilities on Windows. These applications get access to the Windows file system, but you can’t use Bash commands to automate normal Windows programs, or launch Bash commands from the standard Windows command-line. They get access to the same Windows file system, but that’s it. Not every command-line application will work, either, as this feature is still in beta.

How to Install Bash on Windows 10

To get started, ensure you’ve installed the Windows 10 Anniversary Update. This only works on 64-bit builds of Windows 10, so it’s time to switch to the 64-bit version of Windows 10 if you’re still using the 32-bit version.
Once you’re sure you’re using the correct version of Windows 10, open the Settings app and head to Update & Security > For Developers. Activate the “Developer Mode” switch here to enable Developer Mode.

Next, open the Control Panel, click “Programs,” and click “Turn Windows Features On or Off” under Programs and Features. Enable the “Windows Subsystem for Linux (Beta)” option in the list here and click “OK.”
After you do, you’ll be prompted to reboot your computer. Click “Restart Now” to reboot your computer and Windows 10 will install the new feature.

After your computer restarts, click the Start button (or press the Windows key), type “bash”, and press “Enter.”

The first time you run the bash.exe file, you’ll be prompted to accept the terms of service. The command will then download the “Bash on Ubuntu on Windows” application from the Windows Store. You’ll be asked to create a user account and password for use in the Bash environment.

If you’d like to automate the installation of Bash instead, you can run the following command in a Command Prompt window. This will automatically agree to all prompts and set the default user to “root” with no password:
lxrun /install /y

How to Use Ubuntu’s Bash Shell and Install Linux Software

You’ll now have a full command-line bash shell based on Ubuntu. Because they’re the same binaries, you can use Ubuntu’s apt-get command to install software from Ubuntu’s repositories. You’ll have access to all the Linux command line software out there, although not every application may work perfectly–especially in the initial beta releases.
To open the Bash shell, just open your Start menu and search for “bash” or “Ubuntu.” You’ll see a “Bash on Ubuntu on Windows” application. You can pin this application shortcut to your Start menu, taskbar, or desktop for easier access.

If you’re experienced using a Bash shell on Linux, Mac OS X, or other platforms, you’ll be right at home. You don’t need to use sudo, as you’re given a root shell. The “root” user on UNIX platforms has  full system access, like the “Administrator” user on Windows. Your Windows file system is located at /mnt/c in the Bash shell environment.
Use the same Linux terminal commands you’d use to get around. If you’re used to the standard Windows Command Prompt with its DOS commands, here are a few basic commands on both Bash and Windows:
  • Change Directory: cd in Bash, cd or chdir in DOS
  • List Contents of Directory: ls in Bash, dir in DOS
  • Move or Rename a File: mv in Bash, move and rename in DOS
  • Copy a File: cp in Bash, copy in DOS
  • Delete a File: rm in Bash, del or erase in DOS
  • Create a Directory: mkdir in Bash, mkdir in DOS
  • Use a Text Editor: vi or nano in Bash, edit in DOS
It’s important to remember that, unlike Windows, the Bash shell and its Linux-imitating environment are case-sensitive. In other words, “File.txt” with a capital letter is different from “file.txt” without a capital.
For more instructions, consult our beginner’s guide to the Linux command-line and other similar introductions to the Bash shell, Ubuntu command line, and Linux terminal online.

You’ll need to use the apt-get command to install and update the Ubuntu environment’s software. Be sure to prefix these commands with “sudo”, which makes them run as root–the Linux equivalent of Administrator. Here are the apt-get commands you’ll need to know:
  • Download Updated Information About Available Packages: sudo apt-get update
  • Install an Application Package: sudo apt-get install packagename (Replace “packagename” with the package’s name.)
  • Uninstall an Application Package: sudo apt-get remove packagename (Replace “packagename” with the package’s name.)
  • Search for Available Packages: sudo apt-cache search word (Replace “word” with a word you want to search package names and descriptions for.)
  • Download and Install the Latest Versions of Your Installed Packages: sudo apt-get upgrade
Once you’ve downloaded and installed an application, you can type its name at the prompt and press Enter to run it. Check that particular application’s documentation for more details.

Bonus: Install the Ubuntu Font for a True Ubuntu Experience

If you want a more accurate Ubuntu experience on Windows 10, you can also install the Ubuntu fonts and enable them in the terminal.
Download the Ubuntu Font Family from Ubuntu’s website. Open the downloaded .zip file and locate the “UbuntuMono-R.ttf” file. This is the Ubuntu monospace font, which is the only one used in the terminal. It’s the only font you need to install.

Double-click the “UbuntuMono-R.ttf” file and you’ll see a preview of the font. Click “Install” to install it on your system.

To make the Ubuntu monospace font become an option in the console, you’ll need to add a setting to the Windows registry.
Open a registry editor by pressing Windows+R on your keyboard, typing regedit , and pressing Enter. Navigate to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont

Right-click in the right pane and select New > String Value. Name it 000 .
Double-click the “000” string you just created and enter Ubuntu Mono as its value data.

Launch a Bash window, right-click the titlebar, and select “Properties”. Click the “Font” tab and select “Ubuntu Mono” in the font list.


Remember, software you install in the Bash shell is restricted to the Bash shell. You can’t access it from the Command Prompt, PowerShell, or elsewhere in Windows. Software in the Bash shell also can’t interact directly with or launch Windows programs, although the Bash environment and Windows have access to the same files on your computer.
However, you can create Bash shell scripts (.sh scripts) and run them with the Bash shell.