Category Archives: Linux
Linux APT
Advanced Package Tool (Debian)
The Advanced Package Tool (APT) is a software manager. First of all, it is a user interface for the installation and removal of software. it works on Debian, Ubuntu and other Linux distributions. In practice, APT retrieves, configures and installs software packages. It can work with pre-compiled files. It can also compile source code as needed.
Linux OS Basics
Common Commands
The list below presents the most basic and common Linux commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
ls # list files and directories cp # copy mv # move rm # remove mkdir "name>" # make directory pwd # present working directory cd # change directory open -e <name.txt> # open file in text editor echo # print something to stdout cat # concatenates one or more files and sends stdout more # display long text file in chunks grep # search sort # sort text input and send to stdout ps # currently active processes top # list top processes kill <pid> # kill process <pid> killall <proc> # kill process named <proc> ; # separator between multiple commands \ # line continuation (spread a long command over multiple lines) | # pipe the output of one command as the input of another command > # send the output of a command to a file >> # append the output of a command to an existing file ##-----------------------------------------------------------------------------------------## |
Basic System Info
1 2 3 4 5 6 7 8 9 10 |
whoami # display system user name w # display who is online finger <user> # get info on <user> date # print current date date +"%Y% # print current year date +"%V" # week number cal # print month calendar ncal -3 # Display 3 month calendar history # # print last # command inputs ##-----------------------------------------------------------------------------------------## |
Privileges
1 2 3 4 5 6 7 8 |
sudo <command> # run command as root sudo -s # open a root shell sudo -s -u user # open a shell as user sudo -k # forget sudo passwords sudo nautilus # open file manager as root (GNOME) sudo gedit <file> # open and edit file as root (GNOME) passwd # change your password ##-----------------------------------------------------------------------------------------## |
Linux Intro
Installed Base
Linux is a family of free, open-source operating systems (OS) and is the leading OS used world-wide. For example:
- Android has a Linux kernel. It has the largest OS base of general purpose smart phones with a global market share of 73%;
- Linux is the leading OS on servers and mainframe computers. 97% of the top 1 million domain names use Linux. In contrast, 67% of the top 10 million domain use Linux;
Linux Utilities
Linux utilities help to interface with the OS, the server asset and its device stack.
Kernel Information
1 2 3 4 5 |
uname -r # get Linux kernel or OS version uname -a # get all kernel information lsb_release -a # Ubuntu distribution info cat /etc/*-release # Ubuntu distribution with internet help links dpkg -l <package> # Debian info on <package> |
List of Keystroke Bindings
The following command will list all keystroke bindings in place. However, the list is long.
1 |
gsettings list-recursively org.gnome.desktop.wm.keybindings | sort | more # list key bindings |
Clean-up Utilities
1 2 3 4 |
history -c -w ~/.bash_history # clean terminal history rm -f ~/.cache/thumbnails/normal/* # clean the thumbnail cache #1 rm -f ~/.cache/thumbnails/large/* # clean the thumbnail cache #2 rm -r -f ~/.local/share/Trash/files/* # empty trash bin |
File Space Usage
1 2 3 4 |
du -sh * # size of folders (DOOSH!) in PWD (human-readable) du -s * | sort -nk1 # size of folders (sort small to large) du -sh /path/to/folder # size of folders target path du -h --max-depth=1 /path/to/folder # size of all files/folders depth=1 |
Device Utilities
The following commands are Linux utilities that provide information on the device stack for the user’s machine. Additional tables are provided for specific devices that have high frequency interface.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
gnome-system-monitor # launch system monitor df -h # disk usage Disk Usage Analyzer # an Ubuntu app free -t # memory usage (bytes) with total free -gt # memory usage (gigabytes) sudo lspci # list pci buses and devices connected to them sudo lshw -short # comprehensive system info sudo lshw -short -class memory # memory info sudo lshw -class processor # cores and processor info cat /proc/cpuinfo # cores and processors info sudo fdisk -l # List storage devices and partitions sudo lshw -short -class disk # disk drive info sudo lshw -class network # network adapter info sudo lshw -businfo # bus info and device addresses lspci -vnn | grep -1 VGA -A 12 # Data on the graphical card xinput list # list available input devices using ximput utility AlpsPS/2 ALPS DualPoint Stick # track stick device xinput -set-prop "<device>" "Device Enabled" 0 # turn of device; 1 to turn on (look for device name of track stick) cat /var/log/syslog | grep VPN # get VPN connection/error logs |
Linux File Management
Nautilus
Nautilus is the file manager for Ubuntu. Hence, it is a core application. The keystrokes below simplify user interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Ctrl+N # new window Ctrl+Q # close all windows Ctrl+Shift+N # new folder Fn+F2 # rename folder Ctrl+T # new tab Alt+[1-9] # go to tab Ctrl+W # close tab Ctrl+B # open bookmarks Shift+Up/Down # scroll bookmarks Ctrl+D # bookmark open folder Ctrl+H # toggle hidden files/directories Ctrl+F # search files/direcotries Ctrl+R # reload/refresh view Ctrl+[+/-] # zoom in/out ##-----------------------------------------------------------------------------------------## |
Change Directories
It is easy to change directories using the the shell commands below:
1 2 3 4 5 6 7 8 9 10 |
cd or cd ~ # change to home director (see $HOME) cd - # toggle between last two directoriesu cd / # change to root directory cd .. # change to parent directry (up one level) cd Documents/Books # change to Documents/Books directory cd "My Images" # change to directory with spaces in name cd /media/pnr-x1/<dev> # Access USB; device name <dev> cd /media/bxhorn/disk # Access SD card ##-----------------------------------------------------------------------------------------## |
List Files
There are many options to display the files on a hard drive. First, change directories and use the commands below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
ls -a # list all files including hidden ls --color # colored list [=always/never/auto] ls -d */ # list directories only ls -d $PWD/* # list full path names of directories ls -F # list and append one of */=>@| to entries ls -i # list files inode index number ls -l # list files in long format with permissions ls -r # list files and sort in reverse order ls -R # list recursive directory tree ls -s # list file size ls -S # list and sort by file size; human readable ls -t # list and sort by time/date ls -X # list and sort by extension name ls > out.txt # list redirection to output file ls -ltr # order files based on last modified time ls -alFt | grep "2016" # list files from 2016 ls -alhS | more # list files one page at a time set | grep LS_COLORS # get LS_COLOR string for .bashrc file ##-----------------------------------------------------------------------------------------## |
Copy and Move Files
1 2 3 4 5 6 7 |
cp -p file1 file2 # copy files, preserve mode, ownership, timestamp cp -i file1 file2 # copy files with confirmation to overwrite mv -i file1 file2 # move with confirmation to overwrite mv -f file1 file2 # move with no confirmation to overwrite mv -v file1 file2 # move with status printing (metacharacters) ##-----------------------------------------------------------------------------------------## |
Make Directory
1 2 3 4 5 |
mkdir ~\temp # make temp dir under home mkdir -p dir1/dir2/dir3/ # make nested directories export CDPATH=/<dir> # add <dir> to cd base directory (~/.bashrc) export CDPATH=~:/O.RProjects:/Dropbox # add multiple <dir> to cd base directory ##-----------------------------------------------------------------------------------------## |
Linux Aliases
Aliases are shortcuts. They are simple keystrokes commands. Aliases avoid the need to type complex commands and their options. Aliases are easy to create. An alias is rarely more than one line of code. It is typical to store an alias in the hidden .bashrc file. In contrast, aliases can be stored in a dedicated file that is sourced by .bashrc. The .bashrc file is run when the computer is booted. As a result, the aliases are sourced and are placed into memory for immediate use. Examples are listed below:
Linux Hotkeys (Ubuntu)
Hotkeys help to navigate around Linux. They control the user interface. Also, they introduce efficiencies into the user experience.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# Linux Hotkeys --------------- Ctrl+C # halts the current command Ctrl+Z # stops the current command, resume with fg in the foreground or bg in the background Ctrl+D # log out of current session, similar to exit Ctrl+W # erases one word in the current line Ctrl+U # erases the whole line Ctrl+R # type to bring up a recent command # Launcher Hotkeys ------------------ Super[hold] # Opens Launcher; displays shortcuts Super[tap] # Opens Dash home Super+A # Dash app lens Super+F # Dash file lens Alt+H # Ubuntu help # Windows --------- Alt+Tab # Scroll forward across windows Alt+Shift+Tab # scroll backward across windows Super+W # spread and View all open windows Ctrl+Super+W # spread windows current application Ctrl+Alt+4/6 # tile window on left/right Ctrl+Alt+8/2 # tile window on top/bottom Ctrl+Alt+9/7 # tile window top right/left Ctrl+Alt+1/3 # tile wind bottom left/right Alt+F4 # close window Alt+F7 # move window Alt+F8 # resize window Super+Alt+Up/Down # maximize/restore window Ctrl+Super+Down # minimize window Ctrl+Alt+D # Show desktop; minimize all Alt+Enter # launch/close magnifier # Screenshots ------------- PrtScr # screenshot Alt+PrtScr # screenshot of window Shift+PrtScr # screenshot of selected area Ctrl+PrtScr # copy screenshot to clipboard Ctrl+Alt+PrtScr # copy screenshot of windpw to clipboard Ctrl+Shift+PrtScr # copy screenshot of area to clipboard # Other ------- Ctrl+Alt+L # lock the screen ##-----------------------------------------------------------------------------------------## |
Linux Cheat Sheet
Greetings!
Linux users and data analysts will inevitably spend time using the shell or terminal window to execute commands. Many Linux commands are easy to remember. However, many are not. In response, the Linux cheat sheet presents tables with essential commands organized by topic . The tables include useful keystrokes and powerful hacks. The goal is to assist users and analysts to stay focused on solutions and not syntax.
Setting Up A Scientific Programming Environment in Ubuntu
With language, we learn to listen and to speak. With literacy, we learn to read and to write. With programming, we learn how to use and to make software programs. Programming is the new literacy of the digital age. Scientific programming is an essential skill. It allows us to respond to new data structures and new technology, to expand Internet interfaces, to challenge common understandings or wisdom, and to access the control panels of machines and civilization.