Helping new users - Using The Dreaded Terminal

Ideas and discussion


Post Reply
User avatar
wizard
Posts: 1618
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2143 times
Been thanked: 505 times

Helping new users - Using The Dreaded Terminal

Post by wizard »

NOTE: This topic has been transferred to "Getting Started and System Requirements" at the top of the forum.
Renamed as: Using the Terminal
You may still leave comments and suggestions here.

Here's the 21st topic in the Helping new users series

Thanks
wizard

********************************Draft220416 ************************
This topic assumes you are using one of the recommended distros or remasters.

Puppy Linux does an excellent job of providing the user with graphical (GUI) applications and under ordinary operations you will not need to use the terminal. If, however, you have problems and/or ask for help on the forum you may be asked to open the terminal program to help troubleshoot. The sequence is then:
1. type a command
2. press: enter
3. see the output

The terminal in Linux is also sometimes refereed to as the “shell” or “command line interface” (cli). Linux terminal programs are like the MS Windows Command Prompt or cmd. When opened it is a blank black or white window with a (blinking) cursor where you can type commands and see output.

Important: all information entered in the terminal is case sensitive.

There are different terminal programs available in Linux. The two we will discuss are LXTerminal and Urxvt. To open either one:
-click Menu>Utility>Urxvt (or LXTerminal)

Sometimes when using the terminal you have to enter long strings of commands and characters. Using copy and paste whenever possible is the best way to avoid errors.

Selecting (highlighting) text to copy:
-With mouse, hold down the left mouse button and drag the mouse across the text.
-With keyboard, hold down the ctrl key and use the arrow keys to move the cursor over the text.

A Word About Hotkeys
Hotkeys are key sequences that execute an action. Example: if the hotkeys to copy some text are: ctrl c, you select the text, hold down the ctrl key and press the c key. This action copies the text into an area called the “clipboard” . Here are some common hotkeys for copying and pasting that work in just about any application where text can be selected (highlighted using the mouse or keyboard):

ctrl c = copies selected text to the clipboard
ctrl v = paste the contents of the clipboard to the current cursor position

Using these hotkeys you can copy text from forum post to paste it into a terminal, or do the reverse. Unfortunately, the terminal programs don’t honor the “standard” hotkeys above.

Here’s how to do copy and paste into/out of the terminal programs:

LXTerminal

lxterm.png
lxterm.png (5.06 KiB) Viewed 1317 times

-To copy text, select the text and use Edit>Copy
-To paste text, place the cursor where you want to paste and use Edit>Paste

Urxvt

urxvt.jpg
urxvt.jpg (5.21 KiB) Viewed 1317 times

-To copy text, just select it, it is automatically put in the clipboard.
-To paste text, place the cursor where you want to paste and press hotkeys:
ctrl alt v (hold down ctrl alt, press v).

Helpful Hints
When you enter a command in the terminal, it keeps a record of it. You can recall the command by pressing the up/down arrow keys. You can also edit a recalled command without retyping it. The recall is available even after rebooting. This can save you a lot of typing.

Need more help? Join the forum and post your questions in Beginners Help.

Last edited by wizard on Sun Apr 17, 2022 2:39 pm, edited 1 time in total.

Big pile of OLD computers

keniv
Posts: 627
Joined: Mon Jul 13, 2020 2:18 pm
Location: Scotland
Has thanked: 99 times
Been thanked: 65 times

Re: Helping new users - Using The Dreaded Terminal

Post by keniv »

@wizard
I think what you've written hits the right note. I have to admit that if I can use a GUI then I will but I think it would be near to impossible to use puppy without having to resort to the command line at some time. I think new users might be nervous about doing this and might also be baffled by the output. The more that using the command line can be demystified the better.

Regards,

Ken.

User avatar
GMBudwrench
Posts: 98
Joined: Tue Feb 23, 2021 3:19 am
Has thanked: 14 times
Been thanked: 22 times

Re: Helping new users - Using The Dreaded Terminal

Post by GMBudwrench »

And one of the first things I learned was that programs can be started from the terminal without having to navigate into the menu. Also, some programs like inxi, which isn’t an included program but very informative, doesn’t have a menu entry and has to be started via the terminal.

HP G71 Wins10 64 bit, 2.2ghz 320gb hdd, Bionicpup64 on a WD 500gb portable HDD.

Feek
Posts: 396
Joined: Sun Oct 18, 2020 8:48 am
Location: cze
Has thanked: 48 times
Been thanked: 88 times

Re: Helping new users - Using The Dreaded Terminal

Post by Feek »

There are many terminal apps without gui.

But if user requires, even a terminal app can behave as a gui app.

Example for "top" command:
create a new script called "top_gui" in /usr/local/bin with this content:

Code: Select all

#!/bin/sh
urxvt -e top

and make it executable.

This way can be the top command opened in urxvt terminal just by clicking on the script.
Of course, the script can be e.g. dragged on the desktop and "iconified".

user1111

Re: Helping new users - Using The Dreaded Terminal

Post by user1111 »

There are also graphical thing you can do in a terminal ... as in a framebuffer based console.

I compile a kernel sourced directly from kernel.org and busybox sourced directly from busybox.net. Run a minimal kernel+busybox type 'desktop' (initramfs). Into that I add the likes of ssh so I can ssh into servers and run tmux where all my mail, irc, browsing etc. can be done, and include framebuffer programs such as fim that support showing images in that framebuffer.

For me to set that up I originally booted with a boot parameter of vga=ask from which my laptop 1366x768 resolution was something like option 'm' and shown as 3D4 (or something like that without looking). Changing menu.lst to include vga=0x3D4 ... has it always boot into that framebuffer resolution. Tiny font though unless - so use a larger font, I use a large terminus 32b (16x32) font (setfont ter-i32b.psf.gz) ... yielding a nice sized font apperance (the following image is a snapshot taken inside that framebuffer using fbcat)

Image

This is another fbcat snapshot of fim framebuffer image viewer viewing a prior image of a Fatdog desktop snapshot, the next one is stored locally on puppylinux.com, whereas the previous one (above) was stored on postimage.com as unlike local stored images postimage stores at the actual resolution rather than a reduced resolution (so right clicking and viewing the image shows the actual image rather than a scaled down version of the image).

fbcat-snap2.jpg
fbcat-snap2.jpg (89.29 KiB) Viewed 1213 times

.. without X, in a terminal session. fim supports zooming in/out, rotating, flipping, mirroring ..etc. You can also step though a series of images (fim *.png) with the 'n' (next) key.

Browsing in a terminal

fb-HB.png
fb-HB.png (216.58 KiB) Viewed 1208 times

ain't so bad. That's where I'm ssh'd into hashbang, a tmux session with weechat (irc) on window 1, mutt (mail) on 2, and the third active window is running elinks (web browser) connected to this puppylinux forum web site. Navigation and selecting links is via the arrow keys and Page up/down keys. And of course your own IP is hidden, as you're using hashbang/server to initiate and receive web pages requests, web sites can't see that you've ssh'd from (in my case) from the UK to Germany to run the web browser there. That can be awkward at times as some sites may detect a German origin and feed you content in German language text, many of such sites however do also include the option to switch to other languages.

You can also play videos on that framebuffer ..etc. (cvlc).

I use a low/fast compressor choice when building vmlinuz, into which I also include 'initrd' integrally (so no kernel= and initrd= boot lines, just the single kernel= line only) .. where that vmlinuz weighs in at under 30MB. I suspect less than 20MB if I used xz high compression, but that is slower to boot/load and at those sorts of size in the modern world a 10MB difference is near nothing. And that's all inclusive of the kernel and ...

busybox for standard commands
mc as a file manager and text editor. Also handy as a menu/launcher i.e. each folder can have its own menu file set up so you can create a tree of menus/commands that avoids having to type thing in.
squashfs tools for mksquashfs/unsquashfs
ssh (I install the full OpenSSL/SSH so I also have sshfs for mounting remote filesystems, scp ..etc.) so I can ssh into hashbang and view email using mutt, irc using weechat, browse using elinks or lynx (I also install lynx locally as well).
wifi stuff so I can net connect directly (home router) or via my phone (set to being a hotspot).
smtp for tranferring files to/from my phone.

And a beauty is that its enduring, well passed when bugs were ironed out so stable and consistent. With gui you're forever locked into spending some time periodically on upgrading both hardware/software. vi, mc, ...etc. have remained the same for decades.

Where the gui is good is for the likes of office documents, spreadsheets ..etc. and for multi-media. A simple phone nowadays can do much of the multi-media viewing so the desktop is more for creation. Libre Office is nice for laying thing out, but actually in practice I find a simple textual editor to be quicker (less distractions) at entering the text/ideas, then only later import that into writer to spend some time formatting the layout and dropping in images etc.

For web browsing just text can be quicker to identify a source of the information you seek - none of the pop-ups, accept cookies ..etc. distractions. That or a voice based search using the phone.

Remote connecting/sharing is a doddle once your OK with ssh, and being textual based is very fast. For more gui type content there's also the likes of fbvnc that's at least available in the Fatdog repo ... that caters for vnc'ing into gui system (server/desktop).

Building (compiling) your own kernel can be as simple as loading your Puppy versions devx sfs and ... (for Kernel 5.4.152 in this particular case, I tend to build the same kernel release/point version as what Fatdog uses (Fatdog devx being the build system).

Code: Select all

K=5.4.152

wget http://kernel.org/pub/linux/kernel/v5.x/linux-${K}.tar.xz
tar -xvf linux-${K}.tar.xz

cd linux-${K}
cp ../.config .
N=`nproc`
N=`expr $N + 1`

cp ../.config .
yes "" | make oldconfig
yes "" | make -j$N
echo "arch/x86/boot/bzImage (vmlinuz) ready"

# cd linux... folder and run make menuconfig
# to make changes ... such as pointing to your initrd
# (initramfs_data.cpio) and re run make to rebuild.
# First time (above) takes perhaps 1.5 hours, for minor changes
# and re-running it can take just a minute or two.

The trickier part is having a initrd/initramfs ... setup, busybox, your preferred programs ...etc. I just use the same one for that, one I've refined over time with wifi, ssh, ...etc. (my preferred tui (text user interface) 'desktop'). As I build the same kernel version as Fatdog that means I can just drop in Fatdog program along with any libs that program uses. If for instance I want to install calcurse binary then I drop the Fatdog installed version /usr/bin/calcurse into my initramfs, and then run ldd /usr/bin/calcurse to see what libs it uses, and copy those across as well

Code: Select all

# ldd /usr/bin/calcurse
	linux-vdso.so.1 (0x00007ffc4fbff000)
	libncursesw.so.6 => /lib64/libncursesw.so.6 (0x00007fb442d8b000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fb4429f8000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb4427d9000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fb44241f000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fb442fe3000)

Again terminal commands come in handy here
ldd /usr/bin/calcurse >listing
cat listing | awk '{print "cp " $3 " ."}' >files
... and that creates a script with all of the copy files for those libs (some editing is usually required before running). With the program and libs copied into the initramfs, close it, set the kernel to use that and re-run make -j3 and a few minutes later the vmlinux is ready to be booted. Tick yourself as being a advanced hardcore *nixer that uses cli/terminal and builds their own kernels etc., not a *dozer (gui only former Windows user) :)

user1111

Re: Helping new users - Using The Dreaded Terminal

Post by user1111 »

mc with its F2 menu(s) is nice for those longer commands, instead of using aliases you have a visual menu. mc F2, P ... set to power off, mc F2, R to reboot etc. ... if you haven't mc already open, otherwise just F2 P or F2 R ... whatever.

For something more flashy as a framebuffer desktop ... have (looping) video files as 'icons' where each traps selected key(s), where each can be sized/placed where you like on the 'desktop' framebuffer ... and somewhat old BBS style, but with decorations of video files rather than ansii graphics, where you press selected keys to trigger actions (G)oodbye, (M)essage Area, F(iles) area ... type control/navigation. mplayer is a good choice for that IMO. with -loop 0 and -nosound (unless you fancy also having individual icons announcing their action to you, which I guess could be useful for a blind individual who could touch-type).

With basic 'icons' .. (individual videos) not too large in size, that could even be OK with networking. Connect, download the icons (videos) set and a basic script to lay those out on the local framebuffer and just the action (such as F for files) being sent back in order to have the icons associated with that being returned and another desktop formed (or whatever).

I couldn't get mplayer to work with suggested no control keys or any of the other ignore keys modes I saw being suggested (so not to conflict with keys you might want to trigger other actions, q for instance quits mplayer when you might want q to do something else). The workaround I used was to code all of mplayer keys to trigger a invalid mplayer action, so in effect are ignored, in ~/.mplayer/input.conf ...

cat <<EOF >~/.mplayer/input.conf
q DOH
x DOH
...
EOF

so mplayer maps the q key to the command/action DOH ... which doesn't exist, so mplayer doesn't do anything other than log that invalid action

and then fire off the 'icons'
mplayer -vo fbdev -loop 0 -geometry +40+60 -nosound \
-noborder files-video-icon.mp4 >/dev/null 2>&1 &
.. where files-video-icon.mp4 is a video that indicates to press F for files or whatever, using the +x+y geometry to position that icon on the desktop, which just leaves a case statement to capture whatever option was selected and trigger the associated reaction/response.

read -n 1 ANS
case $ANS in
f|F) some-command ;;
q|Q) pkill mplayer; exit ;;
esac

A variable sized icon animated desktop controlled using keyboard keys :)

Attached is a fake .gz file, rename it without the .gz suffix. Example of a video icon (Big Bunny snippet).

Attachments
bunny.mp4.gz
(102.98 KiB) Downloaded 36 times
Post Reply

Return to “Forum Organization & Structure Council”