How to Use DNF History
If you are using a Red Hat/Fedora-based distro, here are some tips on how to use the dnf tool to query your install history:
Retrieve a list of manually installed packages:
$ dnf history userinstalled
Retrieve a list of all transactions:
$ dnf history list all
List the changes in a particular transaction:
$ history list <num>
Undo/rollback a transaction:
$ dnf history undo <num>
Windows Terminal Keyboard Shortcuts
I have to use Windows where I work but I use the terminal as often as possible. Microsoft’s Windows Terminal application makes that experience tolerable. You can even think that you’re using tmux at times…well, not really, but you get the idea.
Here are some of the keyboard shortcuts that I use:
Split current terminal window
Alt Shift - split pane horizontal
Alt Shift - split pane vertical
Jump to other console
Installing Foliate Ebook Reader on Slackware 15
I don’t know about you, but I love reading ebooks and I’ve used Foliate before on other distributions but can’t find it for my OS of choice, Slackware. So, here’s how to install it from source:
- Download the foliate software tarball from here
- Install appstream-glib (which provides dependency appstream-util) using sboinstall
- Install webkit2gtk (which provides dependency WebKit2) using sboinstall
- Build foliate. Instructions are on the GitHub page or just extract the tarball, cd into the directory and then execute the following on the command line:
$ tar zxvf foliate-2.6.4.tar.gz $ cd foliate-2.6.4 $ meson build –prefix=/usr $ ninja -c build $ ninja -C build $ su -c “ninja -C build install”
Archive Only Files In a Directory
If you want to create a tar archive of only the files of a directory and exclude any subdirectories you can use the ls -la command and pipe the output to awk. However you need to remove the first 8 fields from the output and leave all of the remaining parts of the line in case there are spaces in the filename. One quick and dirty way of doing that is to set each of the 8 fields to a blank and then use sed to trim the leading spaces. You can optionally add quotation marks around the filename in your output too.
Edit a Remote File Using Vim
To edit a file remotely using the vim editor, just do the following in a terminal window:
$ scp://username@IP-address//path/to/file.txt
The user must have access to the file being edited.
Echo File Until a Blank Line Is Reached
You can use the awk program to search and print lines in a file. If you wanted to print a file until the first blank line is reached you can use the following command to do that:
awk '$0 ~ /^$/ {exit;} {print $0;}' somefile.txt
Bash Environment Variables
Here are some bash environment variables that are useful to know when you’re using the command prompt:
$0 - name of shell or shell script $1, $2, $3, … - positional parameters to script $# - count of positional parameters $? - exit status of most recent foreground task $- - current options that are set for the shell $$ - PID of the current shell (not subshell) $! - the PID of the most recent background command $DESKTOP_SESSION - path to the current display manager $EDITOR - preferred text editor $LANG - current language $PATH - directory list to search for executables (programs) $PWD - current working directory $SHELL - current shell $USER - current username $HOME - current user’s home directory $HOSTNAME - current name of the host $TERM - current terminal
Bash CLI Keyboard Shortcuts
Here are some quick keyboard shortcuts you can use at the command prompt:
ctrl-l – clear screen ctrl-r – does a search in the previously given commands so that you don’t have to repeat long command. ctrl-u – clears the typing before the hotkey. ctrl-a – takes you to the begining of the command you are currently typing. ctrl-e – takes you to the end of the command you are currently typing in. esc-b – takes you back by one word while typing a command. ctrl-c – kills the current command or process. ctrl-d – kills the shell. ctrl-h – deletes one letter at a time from the command you are typing in. ctrl-z – puts the currently running process in background, the process can be brought back to run state by using fg command. esc-p – like ctrl-r lets you search through the previously given commands. esc-. – gives the last command you typed.
How To Find All of the Shell Scripts In a Directory
This is a quick and dirty way which will list all of the files that are shell scripts:
for i in * do type=$(file ${i}|awk -F, ‘{print $2}’) if [[ “${type}” = " ASCII text executable" ]]; then echo “${i} is a shell script” fi done
How To Use Github Tokens on the Command Line
GitHub’s access policy requires you to use tokens instead of username/password to update your repositories.
To adapt your existing local / cloned repos to token based auth: $ git remote remove origin $ git remote add origin https://[TOKEN]@github.com/[USER]/[REPO] $ git push Clone repos using token based authentication (non public repos) $ git clone https://[username]:[token]@github.com/[accountname]/[reponame]