Sign in to follow this  
Followers 0

HPR - HPR1113: TermDuckEn aptsh

1 post in this topic

I recently discovered apt shell(aptsh), a psuedo shell which gives users of distributions which useapt for package management quick access to the functionality ofapt-get. You should find aptsh in the repositories of Debian baseddistros. Once installed, you can launch 'aptsh' as root from thecommand prompt (i.e. 'sudo aptsh').One of the drawbacks of installing software from the terminal is thatsometimes you don't know the exact name of the package you want toinstall. From the aptsh> prompt, 'ls' plus a search string willshow all the packages that have that string in their names. You cantype 'install' plus a partial package name and use TAB completion tofinish the instruction. The function of the 'update' and 'upgrade'commands are self explanatory, unfortunately, you can't string themtogether on the same line like you can in bash:sudo apt-get update && sudoapt-get -y safe-upgrade Instead, you use the backtick [ ` ] keyto put aptsh into queue mode. In queue mode, you can enter commandsone by one to be launched in sequence at a later time. To bring yoursystem up to date, you could run:aptsh> ` * aptsh> update * aptsh> upgrade * aptsh> ` aptsh> queue-commit-say yes Backtick toggles queue entry, andqueue-commit runs the queue. “queue-commit-say y” tells aptsh toanswer in the affirmative to any queries from the commands executedin the queue in much the same way “apt-get -y safe-upgrade”confirms software updates without user interaction. Apt shell iscapable of other apt related tasks, but I think I've covered the mostuseful ones.The trouble with running aptsh is thatunless you start it in a terminal with the computer and leave itrunning all day (as opposed to opening it as a new shell within youterminal every time you want to update or install), despite theconvienience of package name search and TAB completion, it reallywon't save you any keystrokes. With that in mind, I started lookingfor ways to have the apt shell available at a keystroke (we willleave the wisdom of leaving a shell open with a subset of rootprivileges for another day). I had guake installed, but rarely usedit because I usually have multiple terminal tabs open since I amlogged into my server remotely. [Actually, I had forgotten guakesupports tabbed terminals quite well. You can open a new tab with<Shift><Ctrl>T and switch between terminal tabs by<Ctrl><PgUp> and <Ctrl><PgDn> or clickingbuttons that appear at the bottom of the guake window. I had how,forgotten this until doing further research on this story. Sincethis revelation ruins my story, we will forget about tabbed terminalsupport in guake and not mention it again.]I am also going to assume everyone isfamiliar with guake. If not, suffice it to say guake is a terminalthat pops down in the top third of the screen when you hit a hotkey,<F12> being the default. It returns to the background when youpress <F12> again or click the lower part of the desktop. Itis patterned after the command shell in the game Quake that let youinput diagnostic and cheat codes, hence the name. Since I wasn'tusing guake as a terminal anyway, I wanted to see if I could make itrun apt shell by default. I found you can access guake's graphicalconfiguration manager by right clicking inside the open terminal andselecting preferences. On the first preferences tab, I found“command interpreter”, but since aptsh is only a pseudo shell, itisn't found in the dropdown list. However, one option was “screen”,which would give me a way to run multiple terminals that I thoughtguake lacked. Next, I had to look up how to configure screen. Ifigured there must be a way to make screen run aptsh in one sessionby default, and I found it. In the show notes I've included my.screenrc file from my home folder, which I make with the help ofthis article from the online Red Hat Magazine:**hardstatus alwayslastline hardstatus string '%{= kG}[ %{G}%H%{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%=%{g}][%{B}%Y-%m-%d %{W}%c %{g}]' # Default screens screen -t shell1 0 screen -t apt-shell 1 sudoaptsh screen -t server 2 ssh5150serverscreen -t laptop 3 ssh5150@Redbook **The first two lines set up the screenstatus line, the first puts it at the bottom of the terminal, thesecond sets up the status line to display the hostname and date, andan indicator that highlights which screen windows you are looking at. The # Default screens section below sets up sessions screen opens bydefault. The first line opens up a regular terminal named “shell1”and assigns it to session zero. The second opens a window called“apt-shell” (this is how it's identified on the status line) andlaunches apt shell. The last two log me into my server (host namealiasing made possible by configuring my homefolder/.ssh/config ,thanks Ken Fallon) and my laptop running Fedora respectively. Istill have to cycle through your screen windows and type in mypasswords for sudo and ssh. The configuration could be set up tolaunch any bash command or script by default. The cited articledoesn't include any more configuration tips, but I'm certain thereare ways to set up other options, such as split windows by default. Since I also run screen on my remoteconnection to my server, I have to remember the command prefix is<Crtl>a,a. Ergo, if I want to move to the next window in thescreen session (running under guake) on the local PC, the command is<Ctrl>a, then n. To go to the next screen window in the screensession on my server, running inside another screen session on mylocal PC, it's <Ctrl>a,a,n. So, that's how I learned to run aptshell inside screen inside guake. I can be contacted atFiftyOneFifty@linuxbasement.comor by using the contact form on TheBigRedSwitch.DrupalGardens.Com

Go to this episode


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0