This exercise is a part of Linux servers (ICT4TN021, spring 2018) // Linux-palvelimet (ICT4TN021, kevät 2018) school course organized as a part of Information Technology studies in Haaga-Helia university of Applied Sciences, Helsinki, Finland. Course lecturer Tero Karvinen has defined the original assignment descriptions in Finnish presented in this document in English. Answers and translations have been written by Pekka Helenius (me, ~ Fincer).
Answer: I did this with Rufus Windows application on Microsoft Windows 7 which was run inside Oracle VirtualBox as a virtual machine. Alternative methods include UNetbootin, ISO Image Writer or dd command (default location on Linux: /usr/bin/dd) which is a part of Coreutils. Rufus allows you to create a live USB stick using either ISO or DD method which differ from each other, as the developer has explained on his GitHub site.
Let's take a detailed look for two of these approaches: Rufus on Windows 7 and dd command on Linux (any Linux distribution applies here).
Alternative 1 - Rufus (Windows, GUI-based)
You can use either Windows 7 or 10 (any student/enterprise/server subversion applies here). You can run Windows either in a virtual machine or as physically installed in your mass media storage (SSD/HDD). Whichever method you choose to run Windows, it doesn't really matter. The most important part is that you have a working operating system.
Xubuntu 16.04.3 LTS - Torrent download Xubuntu 16.04.3 LTS - ISO image file directly from a server - 1.2G
Comparing checksums:
If you wanted to make sure the ISO image you just downloaded is valid, you should check its checksum (mainly for security reasons). In this way you make sure that no malicious party has altered the image you trust and the download process has succeeded. You should take a closer look on sha256sum and md5sum values of your ISO image file. The value must match the one which is published on the Ubuntu download site (sha256sum, md5sum).
On Linux: check checksums with commands sha256sum xubuntu-16.04-desktop-amd64.iso and md5sum xubuntu-16.04-desktop-amd64.iso
On Windows: Use Microsoft File Checksum Integrity Verifier or check a CertUtil-based solution given on superuser.com
NOTE: Checking checksums is highly recommended. For instance, Linux Mint network servers were hacked due to outdated server software in 2016, resulting to maliciously injected ISO images uploaded by hostile attackers. In addition, the Linux Mint forum software was affected, as well (user credentials leaked). More about the incident is explained on Linux Mint blog.
Plug in an empty and large enough USB stick into your computer (4GiB should be sufficient). It is highly recommended that you have formatted the stick in advance because Rufus overwrites any existing files existing in the USB stick in order to place required Linux files in the stick. If your stick contained any important files, they should be moved from the stick to somewhere safe location before proceeding here.
Once the stick is emptied (and probably formatted), launch Rufus application. Select the USB stick as a target device in Device menu. All other settings can be left in their default values. Choose downloaded Xubuntu 16.04.3 LTS ISO image file from the dropdown menu located at the right of Create a bootable disk using part. The dropdown menu is presented as a disc icon without any texts.
Click Start, choose ISO method as a writing method once asked. Read the warnings. If all steps have been successfully accomplished so far, proceed with the writing operation.
Wait until the ISO image file has been written into the USB stick. Once done, reboot your computer with the USB stick attached. Immediately the computer has rebooted, press a button which you can access your BIOS/UEFI/Boot options menu with. Choose the Xubuntu 16.04.3 LTS USB stick (which should appear in the boot list). Start the operating system boot-up process bt selecting Try without installing option (this step varies between Linux distribution. More generally, you can also choose Install option and select installation on the live USB Linux desktop environment). Wait until the operating system has been booted up. Start installation and follow the instructions.
The installation process is not defined in detail here because installation steps varies from Linux distribution to distribution. However, basic principle is to install the operating system with good and strong passwords. Encrypted home folder or HDD/SSD partition options should also be considered. After you have successfully installed Linux, detach the live USB stick and reboot your computer. You should be able to access the installed Linux distribution without the USB stick.
When writing and applying passwords, please pay attention to correct keyboard layouts. In my case, I use a Swedish (Finnish) keyboard layout which differs from the default en_US layout. Therefore, mistyping characters can easily happen. Many Linux distributions allow you to change the keyboard layout during the installation process. Unless you're not able to do it in installation window, you can change the keyboard layout temporarily by executing setxkbmap fi in a local shell environment (NOTE: graphical environment is required since the command is a part of graphical X11 environment!). You can open up a local shell by opening a terminal emulator while running Linux from your USB stick. NOTE: changing passwords must be done before writing them in the installation steps!
Alternative 2 - dd command (Linux, CLI-based)
In case you use any Unix-based operating system (Linux, GNU/Linux, Apple MacOS, FreeBSD), you can create a USB live stick by using shell-based dd command. This method does not require a graphical desktop environment. NOTE! Commands on Apple MacOS may not be exactly equal to Linux ones if you use extra parameters in the following commands.
The following instructions assume that you have only a command line environment and you have a working network connection.
a. Centralized server:
wget --directory-prefix=$HOME --show-progress http://cdimage.ubuntu.com/xubuntu/releases/16.04.3/release/xubuntu-16.04-desktop-amd64.iso
b. Torrent download:
transmission-cli -w $HOME http://cdimage.ubuntu.com/xubuntu/releases/16.04.3/release/xubuntu-16.04-desktop-amd64.iso.torrent
sudo mkdir -p /mnt/livestick && \
mkdir $HOME/livestick-backup && \
sudo mount /dev/sdXY /mnt/livestick && \
sudo mv /mnt/livestick/* $HOME/livestick-backup/ && \
sudo chown -R 1000:1000 $HOME/livestick-backup
NOTE: If you have any USB stick partitions mounted already on the system, you should not use /mnt/livestick* location in above commands. Instead, use the path you can extract for the correct USB stick partition with command *mount*.
NOTE! You must be extra careful with dd command. If used wrongly, the command can destroy any data you have in your HDD/SSD or in any storage device. Recovering files is a headache and you really don't want to end up having one! One key principle is to triple check all locations given for the dd command and check that used locations are in correct places (so that input and output operations are being executed for correct devices and the devices don't mix up).
The command syntax (NOTE: not likely the exact command in your environment!) is as follows:
sudo dd status=progress if=$HOME/xubuntu-16.04-desktop-amd64.iso of=/dev/sdb
where /dev/sdb is your USB stick as seen on Linux system. Use correct, your exact device identifier instead of the one shown above.
If you want more instructions how to use the 'dd' command, it is recommended to read the following wiki, for example: Wikipedia - dd (Unix)
The installation process is not defined in detail here because installation steps varies from Linux distribution to distribution. However, basic principle is to install the operating system with good and strong passwords. Encrypted home folder or HDD/SSD partition options should also be considered. After you have successfully installed Linux, detach the live USB stick and reboot your computer. You should be able to access the installed Linux distribution without the USB stick.
When writing and applying passwords, please pay attention to correct keyboard layouts. In my case, I use a Swedish (Finnish) keyboard layout which differs from the default en_US layout. Therefore, mistyping characters can easily happen. Many Linux distributions allow you to change the keyboard layout during the installation process. Unless you're not able to do it in installation window, you can change the keyboard layout temporarily by executing setxkbmap fi in a local shell environment (NOTE: graphical environment is required since the command is a part of graphical X11 environment!). You can open up a local shell by opening a terminal emulator while running Linux from your USB stick. NOTE: changing passwords must be done before writing them in the installation steps!
Answer: sudo lshw -short -sanitize gives the following information (assuming that you have package lshw installed and proper commands sudo and lshw are available on the system):
Detailed comments about the listed devices have been included after each terminal output line (therefore, the output is not exactly as written by the command to stdout/output).
H/W path Device Class Description
P.S. If you frequently listed your hardware on a Linux computer, you should consider creating a bash alias command for this purpose (assuming your default shell environment is bash). Basic idea is to simplify commands you need to type each time you want to do something. For listing hardware, write a the following in your $HOME/.bashrc file (it's a hidden file):
alias listhw='sudo lshw -short -sanitize'
Next time you launch a bash shell session, you should be able to list your hardware by simply executing command listhw, defined in your $HOME/.bashrc file.
If you want to create this command globally accessible for all users, you can write the above code in /etc/bash.bashrc file as root. Alternatively, create a file /usr/bin/local/listhw as root with the following contents:
#!/bin/bash
sudo lshw -short -sanitize
Use command _sudo nano /usr/bin/local/listhw for that. The file is not executable by default. In order to make it executable, apply the following command:
sudo chmod +x /usr/bin/local/listhw
Alternative and additional commands to list hardware are lspci (list PCI devices), hwinfo (defailed output), lsusb (list USB devices). Availability of these commands vary and you may need to install extra packages in your Linux distribution. On Ubuntu, execute the following command:
sudo apt-get update && sudo apt-get install hwinfo pciutils usbutils
Answer:
Let's install three new programs: Thunar (file manager), Gedit (text editor), GParted (mass storage partition editor, alternative GitHub link ) Thunar:
Thunar is a user-friendly and easily understandable GTK+-based file manager. It's not as customizable as Qt-based Dolphin but sufficient for daily basic usage. Thunar is the default file manager for XFCE desktop environment.
Gedit:
Gedit is a simple GTK+-based text editor, targeted to GNOME desktop environment. Alternative text editors are, for example, Mousepad, Kate, KWrite and Geany.
GParted:
GParted is a popular GTK+-based graphical front-end for CLI-based, GPL3-licensed GNU Parted back-end. Similar programs include a Qt-based KDE Partition Manager, targeted mainly to KDE and LXQt desktop environments.
Installation of Thunar, Gedit and GParted on Debian-based distributions
Via official package repositories: On Debian-based distributions (like Xubuntu), you can install the selected three programs with a single command, like:
sudo apt-get update && sudo apt-get install -y thunar gedit gparted
where sudo apt-get update stands for "Update and synchronize package database list to correspond with newer available program versions", && stands for "If the previous command was successful, proceed with the following command", sudo apt-get install -y stands for "Install the following packages without confirming (-y parameter)", and finally, thunar gedit gparted stands for "Application names found in the available repositories listed in /etc/apt/sources.list file and in files in /etc/apt/sources.list.d/ directory and which are parameters for apt-get command".
sudo part before the forementioned commands stands for "Grant me temporary root privileges to execute the following commands as root". It is essential that the current user is in sudo group and all members of group sudo are allowed to gain temporary root privileges (uncomment line %sudo ALL=(ALL) ALL in file /etc/sudoers as root).
By executing the above command, we assume that the system has established internet connection, Dpkg works as intended (it has not already locked file /var/lib/dpkg/lock, for example) and no other installation process is being executed on.
You can execute the command without sudo in root terminal, but accessing root terminal is not highly recommended in server environments. In root terminal, the command would be:
apt-get update && apt-get install -y thunar gedit gparted
You can search for any packages with apt-cache search package-name command. It may not be the primary approach but you can search for packages on official Ubuntu repositories website on Linux Ubuntu distributions (Xubuntu, Ubuntu, Lubuntu, Kubuntu, Ubuntu Bugdie and so on). Alternatively, you can also install packages with aptitude command if you have installed package aptitude. Command syntax for installing packages with aptitude is
sudo aptitude install package-name
Via local packages or from source code:
If you consider installing local packages, keep in mind that you need to track all required package dependencies. This can easily lead to Dependency hell situation. Therefore, installing local packages suits best for commercial, separately distributed software which are bundled with their dependencies and can be installed out-of-the-box without worrying about dependencies.
All installable packages on Debian-based Linux distributions are known as deb packages with suffix .deb. Therefore, local packages can be installed with the following command:
sudo dpkg -i my-deb-package.deb
If any unsatisfied dependencies are present, you should do as usually instructed:
sudo apt-get -f install
Please note that this does not always work, can break your system and make things just too troublesome to sort out. For example, your program may depends on a previous version of a package which is already installed or your system or/and not available on the official repositories. Installing a previous version can seriously break your system. In some rare cases, packages can be offered with two versions where the older version is known as compatibility package, usually installing older library versions to your system, co-existing with newer ones. However, keep in mind that your .deb package must be aware of this compatibility version (so that it depends exactly on that compatibility version instead of the officially named one. This is just a naming issue).
You can force package installation on the system, ignoring package dependencies. In this case, you must know what you're doing, and this approach is really not recommended for Linux novices.
If you want to compile software directly from source, you essentially need dh_make and dpkg-buildpackage commands available on your Debian-based operating system. Usually cmake, make and gcc (GNU Compiler Collection) are required as well. Not forgetting any extra build time dependencies, usually marked with -dev suffix (development headers) in Debian-based Linux distributions. Runtime dependencies can be described in package description.
Any package dependencies (buildtime or runtime) are defined in Debian control file which can be supplied with the package or you need to create and configure it by your own.
On Ubuntu, you can install most essential and widely used build time tools with:
sudo apt-get install build-essential
if you considered installing a remotely available package directly from source, you should find out required runtime and buildtime dependencies with (assuming you have aptitude installed):
aptitude show package-name
where package-name is the package of your choice. Replace this string with the correct name,
Additionally, you can investigate required dependencies by checking any header (.h) files required in C/C++ source files, if the program is based on these languages. By tracking down required headers it is possible to figure out required dependencies in some extent. In addition, check out official websites of the program (GitHub, BitBucket or another homepage), possibly contant the developer and/or check out any supplied library files (suffix is .so) and their dependencies with ldd command. On Ubuntu, you can also check out packages.ubuntu.com for dependencies if the package is available on official repositories.
Please see my practical example 1 and example 2 for compiling software on Linux.
You can also apply patches directly to source code of a program by using diff and patch commands. Patches must be applied before compiling the program.
Removal of packages:
You can effectively remove packages on Debian-based Linux distributions with:
sudo apt-get purge --remove package1 package2 package3
In some cases, package manager suggests you to remove any orphaned packages with:
sudo apt-get autoclean
You can freely explore more apt-get commands with:
apt-get --help
and by reading command-related manual page:
man apt-get
Manual pages in any commands are highly supported in multiple Linux distributions. The command syntax is always the same: man my_command. Additionally, --help paremeter is widely accepted by many Unix/Linux CLI programs.
NOTE: Although Linux distributions don't have any similar to Windows registry hell (unclean registry after software removal), keep in mind that any configuration files created afterwards by a Linux program are not handled by Linux package managers. In other words: package managers can't track files created afterwards by your program. This is mostly a case with personal configuration files in user's home directory on Linux. In addition, any backup files (suffix: .old, ~, .bak, .pacnew...) are not included in the package according to your package manager and, therefore, they may not be uninstalled by simply removing a program. Please see my script for tracking down those files
Other Linux distributions: Main differences between various Linux distributions are:
version modeling: For example, Arch Linux follows rolling release model whereas Ubuntu follows time based release model
package managers: OpenSUSE uses zypper, Fedora uses dnf, Arch Linux uses pacman
package configurations (configuration files, features available for a program by default)
compilation methods for source codes: For example, Arch Linux uses makepkg, Ubuntu uses dpkg-buildpackage
package availability in official repositories: For example, some packages available on Arch Linux are not available on Ubuntu
package versioning syntax: For example, Arch Linux uses version 59.0.1-1 and Ubuntu uses 59.0.1 for a same package
package versions: For example, Arch Linux has newer package version in the official repositories than Ubuntu does.
You can read more at Arch Linux Wiki - Arch compared to other distributions.
Answer:
License information can be retrieved from multiple various sources. Licensing terms have usually been mentioned in source code or documentation, help manual, program website or retriavable from equivalently trusted source.
Thunar is a part of Xfce project and licensed under GPL (GNU General Public License) and LGPL2.1 (Lesser GNU General Public License). Detailed information about the licensing policy can be found on Arch Linux package repository, for example.
Gedit is a part of GNOME project and licensed under GPLv2. Licensing terms are mentioned in Gedit source code.
Gparted is a part of GNOME project and uses GPLv2+ license, according to the official website, bottom section. Exact statement is as follows: "GParted is distributed under the GNU General Public License version 2 or (at your option) any later version."
GPL license is targeted to distribute free sofware under several terms. The license grants permission to use, copy, modify and share a program and its source code. License is accumulating in nature so that any program initially released under GPL and developed further source code must be published and any further restrictions to usage of the program are forbidden. License allows commercial usage of a program. More about the license on GNU project homepage
LGPL license differs from GPL license so that some non-GPL licensed component of a program can be linked to otherwise GPL-licensed program. Therefore, because the program is not fully open source, it can still use LGPL license but not GPL license. LGPL licensed program has less efficient copyleft.
Answer:
Syntax: Closed source program, open source program, purpose of the selected program
Answer: Depending on the final goal/purpose, alternative methods can be used. Creating a backup of whole HDD/SSD's is possible with a single dd command (recommended parameter 'status=progress' with large partitions) and with a USB live stick so that this partition/HDD/SSD is not mounted. More sophisticated tools include Clonezilla, for example. It is recommended to backup a server with slightly different methods.
If the purpose is to copy single files from a location to another location, use cp or rsync command.
cp -Rp /mnt/my_hdd1/somefilefolder/* /mnt/my_hdd2/backupfolder/
where -R stands for "recursive copy" and "-p" stands for "preserve file & folder permissions". Asterix symbol (*) stands for "include all files".
Rsync:
rsync -axHAWXS --numeric-ids --info=progress2 /mnt/my_hdd1/somefilefolder/ /mnt/my_hdd2/backupfolder/
NOTE: If you copy files between ext2/3/4 and NTFS file systems, keep in mind that any permissions stored in ext2/3/4 partition are not preserved in NTFS partition. NTFS is widely used on Microsoft Windows environments whereas ext2/3/4 are widely used on Unix-based (POSIX) environments.
In addition, you must consider any symbolic links included in copy process. Keep in mind to watch out user permissions as well (does the current user have permissions to copy selected files?).