====== [hemmerling] Linux 8/8 - Useful Commands & Tricks ====== Related page: *[[booting.html|Booting from Devices]]. *[[android.html|Google Android]]. *[[linux01.html|Linux 1/8]]. *[[linux02.html|Linux 2/8 - Linux Distributions]]. *[[linux03.html|Linux 3/8 - Linux Boot Loaders, Linux Build Systems, Linux Installers and Linux Implementors]]. *[[linux04.html|Linux 4/8 - Linux Applications, Linux Tools and Linux Drivers]]. *[[linux05.html|Linux 5/8 - SUSE 7.1 Linux on Clevo 2700c Notebooks with SIS630S Chipset]]. *[[linux06.html|Linux 6/8 - Linux with X-Terminals and Terminals]]. *[[linux07.html|Linux 7/8 - Linux on X86, X64 and ARM Computers]]. ===== Machine-specific Programming on Linux ===== ==== uio Framework ==== *The "uio framework" is suitable to avoid Linux license problems for Linux applications with simple, but machines-specific i/o - You may access any memory-mapped hardware by user applications, but you must not provide your source code for any drivers, as there is just a standard Linux mainline driver "mmap" :-). *You may not access legacy and classical PC hardware ( e.g. printer port,.. ) which is connected to the special Intel i/o hardware ports. *There is a special patch available at [[http://git.denx.de/|Git repository of DENX Software Engineering]] for Linux kernel 3.8 to allow the necessary device tree binding by command line commands - this was "missing link" before. It is expected that this option becomes a standard feature of Linux Kernel 3.10, hopefully :-). ==== Select() / Poll() Framework ==== *"include ". *Poll() is a variation of Select(). *Suitable to work with the "uio framework" and it's "mmap" function, to provide interrupt-driven data transfer with any memory-mapped hardware, without the need for thread programming, and it's overhead. *Loop operation: -Select() expects an array of file selectors as input. -It will got to sleep. -In case of a change of the contents linked with the file descriptors, Select() wakes up again. -The application which uses Select() has to explore and find out, which file descriptor contents changed. -The application handels the file descriptor ( read or writes data,.. ). -End-of-loop. ==== Gpio on Lemonboard ==== *On the [[http://www.lemonboard.org/|Lemonboard]] with Ubuntu Linux / Linux, show Gpio Pins: cat /sys/kernel/debug/gpio *Set Gpioi LED Value: echo "1" > /sys/class/gpio/gpio203/value echo "0" > /sys/class/gpio/gpio2/value *Additionally, there is a small application "gpioin". Config the GPIO CSI0_DAT12 to INPUT: echo in > /sys/class/gpio/gpio158/direction echo 1 > /sys/class/gpio/gpio158/active_low echo falling > /sys/class/gpio/gpio128/edge ./gpioin /sys/class/gpio/gpio158/value ==== The Effect ==== *You may now control hardware, even interrupt-driven hardware, from your Linux applications written in high-level language, e.g. C/C++, Python, Perl, Java, running on a standard Linux Kernel 3.10 ( or patched Linux Kernel 3.8 ). *For comparison,, with Python and "Raspberry Pi" platform, you need a special Python library... ===== LInux Commands for Embedded Linux Boards ===== *"cat /proc/cpuinfo". *"ls - l /proc/cpuinfo". *"file hello-world". *"printenv". *For successful use of aa remote NFS filesystem as "root" filesystem, the Linux server option "no_root_squash" is necessary. By this, "root" is not handled as unprivileged user, but the server believes that a true "root" wants to access. *For cross-compilation, add a variable ( e.g. $Cross_compile ) to your makefiles, and define $Cross_compile as environment variable on your host. So that you may use the same makefile to compile both on host and target, but just use a environment variable to create the name of the cross-compiler from the name of the native compiler. So no if-then-else with different compiler calls, but the name of the called compiler is modified to meet the requirements of host and target compilers. ===== Some other useful Linux Commands ===== ==== Forgotten root Password ==== *[[http://www.debiantutorials.org/reset-root-password-debian-gnulinux-etch-286.html|Debian Tutorials "Reset your root Password on your Debian Machine"]] -> Modify Debian Linux boot menu by adding "init=/bin/bash" as additional boot parameter to "/vmlinuz-2.6.18-5-486". *[[http://askubuntu.com/questions/91188/authentication-token-manipulation-error|Ask Ubuntu "Authentication token manipulation error"]] -> "mount -rw -o remount /". ==== "su" vs. "sudo" ==== *[[http://en.wikipedia.org/wiki/Su_%28Unix%29|EN.Wikipedia "su (Unix)"]], [[http://de.wikipedia.org/wiki/Su_%28Unix%29|DE.Wikipedia "su (Unix)"]]. *[[http://en.wikipedia.org/wiki/Sudo|EN.Wikipedia "sudo"]], [[http://de.wikipedia.org/wiki/Sudo|DE.Wikipedia "sudo"]]. *[[http://www.thegeekstuff.com/2009/09/ubuntu-tips-how-to-login-using-su-command-su-gives-authentication-failure-error-message/|The Geek Stuff "Ubuntu Tips: How To Enable Root User ( Super User ) in Ubuntu"]] -> "sudo passwd root". ===== Linux running on Systems with little RAM ===== *Experts told me in the late 1990th, that even if a PC just has 16 or 32 MByte RAM, the Linux swapspace should be 128 MB on the harddisk. ===== Some other Tips & Tricks ===== *[[http://www.askubuntu.com/questions/301484/how-do-i-update-ubuntu-manually|Ask Ubuntu "How do I update Ubuntu manually?"]]. *[[http://www.askubuntu.com/questions/282332/what-is-the-trash-1000-folder-and-how-to-delete-it|Ask Ubuntu "What is the '.Trash-1000' folder and how to delete it?"]] - "This is the folder of you paperbin". ===== Tips for installation and Operation of Debian Linux ===== ==== Debian OS Installation from downloaded DVD ISO Images ==== *Does it work, to create first a bootable USB stick by the "Rufus" ISO2USB tool, and then to copy the 2 additonal DVDS into subdirectories "debian2" and "debian3"? -Sufficient disk space on a 14GB USB stick? YES, for Debian 10.7 :-) -Does the installer "aptitude" find the installable applications, if the USB stick is available at "/media/cdrom/", by soft link ? Yes, it finds and scans the directories of the 2nd and 3rd DVD ( e.g. "debian2", "debian3" ), properly :-). ==== Add the default User to the Group "sudoers" ==== *With Debian 10.7, 11.4,.. the default user is not member of the group "sudoers". This is unexpected, from point of use of an Ubuntu user!!! *If you try any administrative tasks starting with "sudo", even after giving the right password, you are rejected by "Username Is Not In The Sudoers File. This Incident Will Be Reported" :-(. *Especially, the "GDebi Package Installer" quits without error message after entering the right password... *Solution: *[[http://unix.stackexchange.com/questions/179954/username-is-not-in-the-sudoers-file-this-incident-will-be-reported|StackExchange "Username is not in the sudoers file. This incident will be reported"]]. *[[http://unix.stackexchange.com/questions/565665/bash-adduser-command-not-found-debian-buster|StackExchange "bash: adduser: command not found [Debian Buster]"]]. *Add the **username** ( of the user as which you are logged in ) to the group "sudoers". -( Open a terminal ). -su root -( Input root password. root is already member of the group "sudoers" :-) ). -apt-get install sudo -y -//su -l// -adduser **username** sudo -//logout// -chmod 0440 /etc/sudoers -exit -sudo reboot -( Input root password ). -( reboot manually if "sudo reboot" doesn't work ) *[[http://www.tecmint.com/fix-user-is-not-in-the-sudoers-file-the-incident-will-be-reported-ubuntu/|Techmint "How to Fix 'Username is not in the sudoers file. This incident will be reported” in Ubuntu']] - This does not work for me. ==== Installation of Applications ==== === Application: Lua 5.3 === *Lua is shipped on the data DVDs #2 & #3 of Debian Linux 10.7 ( so not on the bootable DVD #1 ) :-). === Application: Executing Graphical Applications like "GEdit", from User "root" === *[[http://unix.stackexchange.com/questions/118811/why-cant-i-run-gui-apps-from-root-no-protocol-specified|StackExchange "Why can't I run GUI apps from 'root': 'No protocol specified'?"]] - "'xhost +' fixed my problem" :-). === Application: Visual Studio Code === *[[http://code.visualstudio.com/docs/setup/linux|Visual Studio Code "Visual Studio Code on Linux"]]. *I passed the installation successfully, by using the "GDebi Package Installer" :-). === Using "dpkg", "apt-get" & "GDebi" Command-Line Solution === *GDebi, dpkg. *[[http://askubuntu.com/questions/40779/how-do-i-install-a-deb-file-via-the-command-line|AskUbuntu "How do I install a .deb file via the command line?"]]. *"Why gdebi? gdebi will look for all the dependencies of the .deb file, and will install them before attempting to install the .deb file. I find this much preferable than 'sudo dpkg -i skype.deb && sudo apt install -f'". *"Unable To Locate Package". *[[http://www.zoomadmin.com/HowToInstall/UbuntuPackage/lua-check|ZoomAdmin "How To Install 'lua-check' Package on Ubuntu"]]. -"sudo apt-get update -y". -"sudo apt-get install -y lua-check". *Error message "E: Unable to locate package lua-check" :-(. *[[http://askubuntu.com/questions/1325811/unable-to-locate-package-when-the-file-is-right-in-the-directory-its-a-d|AskUbuntu "Unable to locate package — when the /file/ is right in the directory (it's a .deb) [duplicate]"]]. *[[http://www.linuxfordevices.com/tutorials/ubuntu/fix-unable-to-locate-package|LinuxForDevices "How to fix 'Unable To Locate Package'? – (Fix with APT Sources)"]] *[[http://wiki.debian.org/ftp.debian.org|Debian Wiki "ftp.debian.org"]]. *[[http://deb.debian.org/|deb.Debian.org]] - Add these 3 lines to "/etc/apt/sources.list": deb http://deb.debian.org/debian unstable main deb http://deb.debian.org/debian-debug unstable-debug main deb http://deb.debian.org/debian-ports unstable main === Using "aptitude", "tasksel" === == aptitude == *aptitude is not installed by default, with virgin out-of-the-box Debian Linux 10.7. *Installation: "sudo apt-get install aptitude". *Message "Media changed: please insert the disk labeled 'Debian GNU/Linux 7.10.0 _Buster_ - Official amd64 DVD Binary-1 20201205-11:17' in the drive '/media/cdrom/' and press Enter". *[[http://unix.stackexchange.com/questions/125859/media-changed-please-insert-the-disk-labeled-debian-gnu-linux|StackExchange "Media changed: please insert the disk labeled 'Debian GNU/Linux"]]. *Expert suggestion: "sudo mount /dev/sdb1 /media/usb0", "sudo apt-cdrom -m -d=/media/usb0 add". *This command works for me properly: -( remove/delete all the entries in "/etc/apt/sources.list" ). -"sudo gedit /etc/apt/sources.list" -"sudo apt-get update". -"cd /media". -"sudo ln -s '/media/node8/DEBIAN 10_7/' cdrom". -"sudo apt-cdrom -m -d='/media/node8/DEBIAN 10_7' add". *If you want to undo: -"sudo rm -r /media/cdrom/". *[[http://www.linuxize.com/post/how-to-create-symbolic-links-in-linux-using-the-ln-command/|Linuxize "Ln Command in Linux (Create Symbolic Links)"]]. *[[http://www.stackoverflow.com/questions/9587445/how-to-create-a-link-to-a-directory|StackOverflow "How to create a link to a directory [closed]"]]. == tasksel == *A task is a collection of several individual Debian packages all related to a specific activity. Tasks can be installed through the "tasksel" program or through "aptitude". *The tasksel installation options are also offered during installation of Debian Linux. === Using "Synaptic Package Manager" === *[[http://wiki.debian.org/Synaptic|Debian Wiki "Synaptic"]]. *If you run the "Synaptic Package Manager" on virgin Debian Linux 10.7, there is the error message "You are using Wayland environment, Synaptic will continue without administrative privileges. To make Synaptic fully functional, please restart your session without Wayland". "Starting 'Synaptic Package Manager' without administrative privileges" :-(. *I failed to fix it on a virgin out-of-the-box Debian 10.7, these instructions are not really helpful for me as newbie: *[[http://www.linuxquestions.org/questions/debian-26/run-synaptic-with-wayland-enviroment-4175684684/|LinuxQuestions "Run synaptic with Wayland enviroment"]]. *[[http://forums.debian.net/viewtopic.php?f=6&t=142634|Debian Users Forum "Wayland,Synaptic continue without administrative privileges"]]. *[[http://www.debianforum.de/forum/viewtopic.php?t=174341|Debian Forum "[gelöst]Debian 10 Gnome 3.xx Synaptic unter Wayland"]]. === Resources ==== *[[http://www.debian.org/mirror/list|Debian.org Manual Deutsch "Debian worldwide mirror sites"]]. *[[ftp://ftp2.de.debian.org/debian/|ftp2.de.debian.org/debian/]]. *[[ftp://ftp.de.debian.org/debian/|ftp.de.debian.org/debian/]]. *[[http://www.debian.org/doc/manuals/debian-reference/ch02.de.html|Debian.org Manual Deutsch "Kapitel 2. Debian-Paketmanagement"]]. *[[http://www.debian.org/doc/manuals/debian-faq/pkgtools.de.html|Debian.org Manual Deutsch "Kapitel 8. Die Debian-Paketverwaltungswerkzeuge"]]. *[[http://wiki.debian.org/PackageManagement|Debian Wiki "PackageManagement"]]. *[[http://wiki.debian.org/PackageManagementTools|Debian Wiki "PackageManagementTools"]]. ===== Appropriate OpenDirectory Directory Pages ===== *[[http://www.dmoz.org/Computers/Software/Operating_Systems/Linux/|OpenDirectory "Top: Computers: Software: Operating Systems: Linux"]]. *[[http://www.dmoz.org/Computers/Software/Operating_Systems/Linux/Embedded/|OpenDirectory "Top: Computers: Software: Operating Systems: Linux: Embedded"]]. *[[http://www.dmoz.org/Computers/Software/Operating_Systems/Linux/Platforms/|OpenDirectory "Top: Computers: Software: Operating Systems: Linux: Platforms"]]. *[[http://www.dmoz.org/Computers/Software/Operating_Systems/Embedded/|OpenDirectory "Top: Computers: Software: Operating Systems: Embedded"]]. *[[http://www.dmoz.org/Computers/Software/Operating_Systems/Realtime/|OpenDirectory "Top: Computers: Software: Operating Systems: Realtime"]]. *[[http://www.dmoz.org/Computers/Software/Operating_Systems/Realtime/Open_Source/|OpenDirectory "Top: Computers: Software: Operating Systems: Realtime: Open Source"]]. *[[http://www.dmoz.org/Computers/Software/Operating_Systems/Realtime/Linux/|OpenDirectory "Top: Computers: Software: Operating Systems: Realtime: Linux"]]. {{tag>Linux}}