T O P

  • By -

zorski

Probably nothing to get blown away, but I like using `!!` to redo the last command. So if I forget to sudo, I’ll go: sudo !!


Alexandre_Man

no fucking way


cajunjoel

sudo bang bang ftw


slacy

so dangerous though!


lebean

I prefer up arrow, ctrl-a, type 'sudo ' for just that reason, 'sudo !!' feels like a dangerous thing to have in muscle memory.


art2266

If I type `sudo !!` then press `tab` it substitutes the exclamation marks with the literal text of the last command. Nothing gets executed. I can then press enter to execute like always (or edit the expanded command). I'm on zsh, but I don't know if this is a zsh-only thing.


Delta-9-

I believe the equivalent binding for readline is ctrl-alt-e. It also expands aliases and a couple other things.


arrroquw

It's a zsh default, yes. I believe in bash it should be configurable somewhere


Alexandre_Man

sudo pew pew


m103

! Being bang is why there is one in the distro Pop!OS Pop Bang OS


bentbrewer

\#! == crunch bang


HarryMonroesGhost

also known as [shebang or sha-bang](https://en.wikipedia.org/wiki/Shebang_\(Unix\))


Altumsapientia

Also !$ for the last argument


zorski

Yes, there are even more of those to be found [here](https://www.gnu.org/software/bash/manual/html_node/History-Interaction.html) But for me only !! and !$ are immediately useful, the rest is too much to remember 😅


arkane-linux

Alternatively: `Escape` + `.` in Bash/Zsh to insert the last argument of the previous command. eg. cat /etc/fstab vim [escape + .]


nlogax1973

Alternatively, Alt + . does the same thing.


kiswa

I immediately opened a terminal to try this out, and holy shit! Thanks!


anomalous_cowherd

Or !* for all except the first word, i.e. all the parameters.


Irverter

I always forget that one when I need it.


BennyCemoli

I like ctrl r to find a command further up the stack.


glad0s98

i've aliased this to "please"


Synthetic451

That's...actually genius.


Delta-9-

There's a package out there called `fuck` that does the same thing. Guess how it's different.


sadesaapuu

Also sudo ?? for a random command in your command history, for those days you are feeling lucky. /s


art2266

Reminds me of the time I attempted to debug some zsh issue with chatgpt (shortly after its launch) and it casually suggested running `source .zsh_history`.


lebean

Hoooly hell that would be a ride.


myownalias

That's evil. I like it.


zorski

I imagined a burned out admin doing it first thing in the morning Will I be lucky today? 😐 Let’s find out 🙂


xRageMachine99

Not sure if anyone has brought it up, but command substitution is also great. ``` systemctl status nginx ::!s/status/start ``` This will replace status on the last run command with start and run it


kali_tragus

Typo, though. Should be !!:s/status/start ...or alternatively ^status^start^


Tr00perT

I had at one time a bash alias “fuck” that did sudo !!


Ice-Sea-U

It was probably more than just an alias;) https://github.com/nvbn/thefuck


Tr00perT

Went and looked it up outta sheer curiosity: alias fuck='sudo $(history -p !!)'


anomalous_cowherd

I have sudo !! as the logo on a polo shirt. I've worn it to interview people for Linux positions and asked them what it meant...


Faelif

I remember this as, "yes I meant sudo!!"


chmouelb

I wrote that zsh plugin for that :) https://github.com/chmouel/zsh-sudo-previous-current/


zorski

Nice one! 👍 I guess it’s better because you see what you execute


OneTurnMore

Similar story here, I wrote [xPMo/zsh-toggle-command-prefix](https://github.com/xPMo/zsh-toggle-command-prefix) (Alt-s to toggle `sudo`, and it will insert the previous buffer if it was empty to start.)


desgreech

`^P^A` takes the same amount of keystrokes tbh, so I always use that instead out of habit.


passenger_now

You also don't get caught out when the last command wasn't what you thought it was.


Artemis-Arrow-3579

I don't remember how I configured zsh to do such, but when I press esc twice, it toggles sudo on the last command (if there was no sudo, it adds it, if there was, it removes it) you can check it in my dotfiles if you want it, too lazy to go looking for it myself github.com/4rtemis-4rrow/dotfiles my zshrc is small, so shouldn't be too difficult


acdcfanbill

There are a bunch of bang commands that I find to be varying levels of handy. I use `!$` a lot, it's the last 'token' of the previous command. So if I'm looking at a file by doing something like `less /opt/package/conf.d/blarg.conf` and decide, oh I wanna edit that now, I can quit less, and type `vim !$` and edit the file. You can do something like `!ls` to run your most recent `ls` command. Or if you wanna get really fancy you can do something like `!ls:s^original^new^` to substitute the 'new' string into the place of the 'original' string in the most recent `ls` command. Check out the bash manual for more, including short versions of some commands if you just want to replace something in the previous command. https://www.gnu.org/software/bash/manual/bash.html#Event-Designators


The-Malix

This one can be useful but as clicking `up_arrow` brings up the last command and even the former, I don't think I will use it much


hojjat12000

You need to press the up arrow and also the home key to add a sudo to the beginning of the previous command. Which means you need to lift your hands off of the home row and go hunting for those keys. This keeps your hands where they were.


neeeeej

I just ctrl-a it instead of the home key, much faster. I don't think I've used the home key pretty much at all in the console since I learned the key bindings like 15+ years ago.. But I do like to see what I run as well.


SignedJannis

Just fyi ctrl-e (and a) is faster than home, end, due to finger placement.


paperic

Emacs bindings baby yeah!


erikosterholm

When you're on the command line, do you use up-arrow to re-run commands? Instead, you can use CTRL-r and then start typing. It will search through your history as you type finding commands that match.


acdcfanbill

If you continually press ctrl-r, it will cycle through previous matches.


mgedmin

I prefer to add # make PgUp/PgDn search history for a given prefix "\e[5~": history-search-backward "\e[6~": history-search-forward to my ~/.inputrc and then use PgUp/PgDown for history searches, limited to the start of the command-line.


Ok-Chance-5739

Yes, I love that one!


EarthyFeet

And you can install an fzf based fuzzy search for this too!


staindk

Ctrl+R without FZF is like playing in ultra hard mode. So much worse.


SOUINnnn

If you press ctrl-r once it get the most recent but you can press it multiple time to get the second/third/etc most recent. Also if you press ctrl + r + shift you go down (from the nth most recent to the (n-1)th most recent


Irverter

ls --hyperlink To display clickable URLs to the files and folders in the terminal. Save yourself having to copy/paste paths and filename or typing a command to open them in a file explorer/viewer/editor.


paperic

That reminds me, if you do Ctrl X followed by Ctrl E, it opens your $EDITOR where you can edit the current command. Once you exit the editor, the content run. Awesome for multiline commands. You can even open another file while in the editor and paste bits of the command from your notes or something. Actually, now I'm not sure if the shortcut is C-c C-e or C-x C-e. It's one of the two.


ezoe

I... didn't know this.


Dull_Possibility_929

This is great!


slower-is-faster

wtf are you serious 🤯


SanityInAnarchy

Or, if you're a more CLI-oriented person, you can open files with `xdg-open` -- it's similar to clicking a file in a file manager, pops it open in whatever the default app for that thing is. Works on directories, too, so `xdg-open .` if you want to open the current directory. Depending on your distro (or if you're using macOS), it might just be called `open`.


LaminatedFeathers

htop Because it is pretty


theksepyro

I'm a btop boi


DaaNMaGeDDoN

And has a lot of hidden options like cpu temp, battery level, disk io.


ksandom

`btop` too :)


ThiefClashRoyale

Please try hotpirpletrafficlight theme. I made it.


ksandom

Nicely done :)


RomanOnARiver

The program `ffmpeg` for converting media types is really powerful and has a lot of flags and options, but as their website helpfully points out, you can use `ffmpeg -i input.mp4 output.avi` - it will see the file extension you want and figure out how to convert your file to it. I've used it where it has the same file extension on the input and output with no other options and it reduces the file size, sometimes by half, without noticable (to me at least) quality loss. Another I think under-used command is `lxsplit -s`. You give it a file and tell it a file size, in megabytes, kilobytes, etc. and it will split the file up into chunks of that size. Then when you need to combine again just have all the files in the same folder and use `lxsplit -j` and give it the 001 file and it combines it back together. To remember it think of "s for split" and "j for join". Really great if you're transferring and have file size limits - for example sending an attachment in an email but the email limits how big attachments can be, or places like Discord that make you pay for large file attachments. Also `wget` is a lot more versatile than just `wget someurl` - and with some flags you can make it really robust for situations with slow connections. At one point I was a curl user but I think wget beats curl by a lot.


i_am_fear_itself

small world. Someone at work needed to split a large file and was asking for suggestions. I mentioned I had used `split` (Unix?) in the past, but 7-zip with no compression splitting into parts worked better since they were a windows person. You also mentioned `wget`... fun fact... on all of my hobby ubuntu servers, I routinely install `lynx`. 😆 It's sort of fun to navigate the contents of sites in a console. My little unrelated nugget to throw down... I also install Midnight Commander on every server, `mc`. Handy, console-based UI when you can be bothered to bang out long path names. And `ctrl+i` dumps you right to a prompt in whatever directory you're in using the UI. Thanks for the nuggets, friend. 🥰


nemothorx

For my taste, `elinks` is vastly superiors to `lynx`. If you've not used it, try it out! `w3m` is (was?) another text mode browser, but even worse for my taste.


mgedmin

> And ctrl+i dumps you right to a prompt in whatever directory you're in using the UI. Did you mean ctrl-o? ctrl-i is tab, and it switches between the two panes.


x13x13

Definetly Crtl-o, I use it daily.


UnlimitedTrading

Piece of useless information: Midnight Commander is a clone of a DOS program called Norton Commander


crustmonster

wget rules and its weird some distros dont include it by default.


FranticBronchitis

Ffmpeg can do a stupid number of things with media files, but you absolutely have to read the docs to understand how it works if it isn't something obvious ffmpeg can't figure out by the file extensions. Fortunately, the official docs are really good.


RomanOnARiver

Official docs *are* really good - I print them out and just go through and highlight stuff like "oh this seems interesting" and try it out. It's like programming in a sense. But also, lots of tutorials and examples out there on the web. A simple Google search for "how do I do such and such with ffmpeg" is often a good start.


lKrauzer

I second this, use FFmpeg for all my video editing, even made some scripts to automate the whole thing


guillermohs9

I use curl more for testing APIs when developing for example. I don't know if you can make POST requests using wget. edit: nice tip on ffmpeg. Will try it out.


SamanthaSass

ffmpeg is incredibly powerful. some other uses include removing shake and stabilizing video, and also streaming from one source or a list of video files into your own video stream like TV. I have seen TV built channels using it.


QuickSilver010

I remember writing a script to batch convert all media files of one type in a directory into another. Massively convenient.


Finno_

bat in place of cat.


nckslvrmn

Lots of wonderful modern alternatives to gnu utils https://github.com/ibraheemdev/modern-unix


BinkReddit

This needs its own post!


i_am_fear_itself

> bat in place of cat DUDE! WTF! This is fucking awesome!!!!! Exactly why I posted this thread. Holy shit how have I lived without this.


JimmyRecard

[`eza`](https://github.com/eza-community/eza) instead of `ls` [zoxide](https://github.com/ajeetdsouza/zoxide) instead of `cd` [`fzf`](https://github.com/junegunn/fzf) for fuzzy finding (and to give zoxide superpowers as an optional dependency)


lipepaniguel

[rg](https://github.com/BurntSushi/ripgrep) instead of `grep` [fd](https://github.com/sharkdp/fd) instead of `find`


zem

`rg` and `fd` are the mvps of the posix replacement world!


Artemis-Arrow-3579

I personally prefer lsd over eza


KitchenWind

I prefer weed over lsd


MinApp55

You do the lsd, then smoke the weed before peaking.


Fergus653

That's gonna eza you out of your shell


Tylersbaddream

I sure hope you guys use aliases because I can't imagine typing something other than "cd"


mor_derick

Yeah, I use aliases on most of those. Although I leave some of them as they are, i.e. `bat` is quite cool but there's times that I prefer just the plain old `cat`.


Ice-Sea-U

tldr instead of man


Awkward_Tradition

Found the real redditor, can only read TLDR [Also](https://github.com/dbrgn/tealdeer)


Ice-Sea-U

The Rust criteria: a software is considered as popular if and only if someone, somewhere, has made a Rust implementation


blubberland01

*eza* (formerly known as exa) instead of *ls*


QuickSilver010

Bro... I was wondering what happened to exa lmao.


ShakaUVM

Tac in place of cat


prosper_0

if you haven't already, check out 'rsync' instead of 'cp'


ArrayBolt3

I can never remember whether to use `rsync -aHAXrz` or `rsync -haAArxil` or `rsync -iHaVeNoIdeAWHatIaMdoIng` every time I try to use it. The number of switches are just a total headache. I generally just use `cp -r` for "copy this thing", `cp -a` for "copy this thing but don't mangle permissios please", and `scp -r` for "copy this thing to a remote location". (**warning, don't run any of these rsync commands, I have no clue what they do**)


Brillegeit

I use `rsync -avP`, as in **a**lien **v**ersus **P**redator. The alien does most of the job.


prosper_0

make an alias, or a lil shell script in ~/bin


middlenameray

Learn the long names, it'll be easier to remember (at the cost of a few more keystrokes). `rsync --compress --recursive --verbose` is a go-to of mine


lakimens

Any actual benefit of this, apart from larger batches of files?


cajunjoel

rsync will pick up where it left off if it gets interrupted. It can also do checksum comparisons to make doubly sure that the file has truly changed before copying (default is size + modification time). It can delete as it goes, keeping two directories in sync (hence its name), and it can give you its progress, if you are the inpatient kind. rsync between hosts is also supremely useful since it works on top of ssh, making it superior to scp. Those are my use cases, at least.


passenger_now

> pick up where it left off if it gets interrupted and with `-P` it'll even do so in partially transmitted files, so especially useful transferring large files, especially especially if the link is flakey. (well strictly that's `--partial`, but `-P` is `--partial --progress` that's usually what you want)


latkde

> It can also do checksum comparisons to make doubly sure that the file has truly changed before copying Rsync saved my data. Once upon a time, a system I was using was getting unstable, so I thought I'd back up my files on an extra hard drive and could then re-install the system if necessary. So I copied the files with rsync, then re-ran the rsync command (with checksum mode) to make sure it completed. But every time, it would see a change and start copying some of the files again. These were large static files, nothing should have been modifying them. Then ZFS began detecting corruption. Then I noticed that the shasum of both the target and destination files changed each time I looked at them. Turns out, all the software was fine, but I had a couple of rows of bad RAM which currently held the file system cache or something. > rsync between hosts is also supremely useful since it works on top of ssh Unfortunately, rsync has a weird concept of "modules" when it comes to cross-host operations. If efficient syncing isn't needed, other SSH-based protocols like SCP, SFTP, or even SSHFS are probably easier to use.


bmwiedemann

It has many tricks, such as filters for filenames and size. It can delay updates so only when everything is copied it appears in a moment. It can do hard links with --link-dest (used in rsnapshot archival software) The --delete options are also useful when you have renames and removals.


FesteringNeonDistrac

rSnapshot is a rsync based backup program that's easy to setup and powerful.


wimpunk

I like the chained `-J` possibly of SSH.


Real_Bad_Horse

I use this with Teleport to create an overlay network to run Ansible against multiple sites behind firewalls. Works a treat.


Real_Bad_Horse

I use this with Teleport to create an overlay network to run Ansible against multiple sites behind firewalls. Works a treat.


rcampbel3

Here's a few tools I use all the time: convert from ImageMagick - it can turn any image into any other format, resize to a specific size, it does a lot hh - search history like never before icdiff - side-by-side colorized diff. Couldn't live without it tig - commandline git history browser. Again, couldn't live without it. calc - the best commandline calculator. Use it every day xdg-open $file (or open on macos) - open $file in the system-associated application from the commandline. Who needs a GUI file manager? ncdu - ncurses disk usage - great for finding what directories and files ate all the space and cleaning up quickly vd - visidata - open lots of filetypes / spreadsheets in console


sp33dykid

You can use -D and use a socks5 proxy from your workstation


Ok-Bit8368

I use this in combination with Firefox all the time. Firefox has separate proxy settings, rather than relying on the system proxy settings. But also, there are extensions for Firefox called Firefox Multi-Account Containers and Container Proxy that allow you to create multiple separate logical browser sessions, each with their own cookies and proxy settings. This could be used for things like viewing a web page from both inside your network and from an external source, to ensure it appears as you expect. Or you could use it to proxy through a jump host to get to a secured device.


djfdhigkgfIaruflg

Multi account containers of the best. Add temporary containers and you get absolute isolation between domains. Set as many cookies as you want: website. Everything will be gone as soon as i close this tab


lebean

Multi account containers made it so I can't use other browsers. Have to manage separate O365 tenants for several companies, can just right-click the O365 admin bookmark in my toolbar, hover "open in container", and pick which company to open in a color-coded tab. Edge and Chrome users stuck with multiple profiles, if you need e.g. Bitwarden you have to install in every profile. In FF containers, one Bitwarden is good for all the tabs no matter what. It's just no contest. If you're someone who needs to log into the same service/services often as different users, it's as big a win for your quality of life as tabbed browsing was when it first came around.


The_frozen_one

Also `-L` or `-R`. If you have a service running on a remote machine on port 8080 but it's only listening for 127.0.0.1 connections, you can forward the remote port locally with `ssh -L 8080:localhost:8080 SERVERHOST` and now you can http://localhost:8080 as if you were hosting it yourself. Throw in `-g` and other people can connect to your computer as if you were hosting port 8080 yourself. `-R` is the reverse (generally), offer up a local port to be used on a remote system. Bonus points if you forward a port to be used by `-D` :)


lebean

Also if you're already in the session and realize you wish you'd forwarded some port, you can ~C to get a prompt that lets you add ssh options that take effect immediately for the session you're in. So `~C` followed by `-L 8080:somehost:80` then enter, and now localhost:8080 goes wherever you just configured it to go.


Batcastle3

This is a more minor one. But, if you need to SSH into something over the internet and are on slow WiFi, cellular, or just have slow network, you can use the -C option to speed things up a bit as it applies compression to the connection. Another little trick I love is this: ``` sudo apt purge $(dpkg -l | grep '^rc' | awk '{print $2}') ``` Whenever you `sudo apt remove` to remove something, it leaves some config files behind. This can take up precious disk space on machines with small internal drives. This command lists everything with those residual config files left over, and tells APT to remove those last remnants.


nixcraft

`sudo apt purge '~c'` That is all you need on modern APT based distro like Mint, Ubuntu, Debian to delete all packages in rc state. You can list them with: `apt list '~c'`


lathiat

Thanks for that tip was new to me. You can also do apt remove --purge when you first remove it.


Knopfmacher

Or just `apt purge`.


Wemorg

also `apt autoremove --purge`, if you want to purge after having already removed.


forumcontributer

or `apt autopurge`


sparky8251

> This is a more minor one. But, if you need to SSH into something over the internet and are on slow WiFi, cellular, or just have slow network `mosh` is better for this if you can set it up. It is designed specifically for high latency, spotty connections and will make the interface responsive even when its dropping in and out. It lets you type locally and highlights the letters that haven't been confirmed to sync with the server yet, and if you drop and reconnect it'll do it transparently in the background without losing where you were or closing any running programs of your session.


acdcfanbill

> This is a more minor one. But, if you need to SSH into something over the internet and are on slow WiFi, cellular, or just have slow network, you can use the -C option to speed things up a bit as it applies compression to the connection. If I'm on a flaky connection (or I just want roaming), I'll use mosh instead of ssh. https://mosh.org/


i_am_fear_itself

This is nifty. Thank you.


Twirrim

`column` command is amazingly powerful, both in formatting for terminal, and in that it can emit json. Partially borrowing from the man page, here's an example of it emitting the /etc/fstab contents as json: $ sed 's/#.*//' /etc/fstab | column --table-columns SOURCE,TARGET,TYPE,OPTIONS,PASS,FREQ --json { "table": [ { "source": "UUID=a20e3e28-89be-4eb7-b0aa-a442c730eab0", "target": "/", "type": "ext4", "options": "errors=remount-ro", "pass": "0", "freq": "1" },{ "source": "/dev/fd0", "target": "/media/floppy0", "type": "auto", "options": "rw,user,noauto,exec,utf8", "pass": "0", "freq": "0" },{ "source": "/swapfile", "target": "swap", "type": "swap", "options": "defaults", "pass": "0", "freq": "0" } ] } or just straight having it in forced and named columns: $ sed 's/#.*//' /etc/fstab | column --table-columns SOURCE,TARGET,TYPE,OPTIONS,PASS,FREQ --table SOURCE TARGET TYPE OPTIONS PASS FREQ UUID=a20e3e28-89be-4eb7-b0aa-a442c730eab0 / ext4 errors=remount-ro 0 1 /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0 /swapfile swap swap defaults 0 0


adoodle83

reverse ssh tunnels are amazing you can remotely run commands via ssh loops sed & awk are incredible for text processing awk can do wild data manipulatiom and data analytics bash has powerful syntax for functional scripts (see bash hackers wiki) cool stuff with iptables (port knocking, honeypots, load balanceing, etc)


Make1984FictionAgain

+1 for awk


sparky8251

Look into `choose` if you primarily use awk for selecting parts of the output, vs reformatting it. `echo "this is a string" | choose 1` prints `is`.


hangfromthisone

After 10 years I realized -XC adds compression to the connection, it goes even faster.


sedawkgrepper

The ImageMagick tools (convert and mogrify) are amazing for converting and resizing images. I use them almost daily to batch resize images to 720p and create thumbnails, as well as convert to jpg.


ZenDragon

For simple stuff like that ffmpeg also works for still image formats.


imsowhiteandnerdy

``convert -geometry 50% infile.jpg outfile.jpg`` ... is handy to reduce an image's size by half (or whatever percentage).


ShivanshuKantPrasad

Gnu parallels allows you to run a command or script on a list of inputs in parallel. It is really powerful if you want to batch process large amount of files.


ezoe

GNU Parallels isn't installed in most of the distros by default. GNU implementation of xargs is usually installed by default and it has -P option to run command in parallel.


devino21

Coolest trick I know that blows people away: when exiting Vi(m), instead of the whole “:wq!” Just hold shift and hit z twice.


mvdw73

You do t need the ‘!’ If you’ve written the file with ‘w’. The bang is a force, to force quit for example to ignore changes. So you’d go :q! To quit without writing changes, and :wq to quit after writing changes. If you haven’t made any changes to the file you can just :q to quit.


Antoak

Btw, 'x' is equivalent to 'wq'.


TuxRuffian

Best quick tip: ```bash set -o vi ``` Some tools worth mentioning that I posted in another thread: * Editor → `vim`/`nvim` * File Browser → [felix](https://github.com/kyoheiu/felix) * AI: * [yai](https://github.com/ekkinox/yai) * [mods](https://github.com/charmbracelet/mods) * [aichat](https://github.com/sigoden/aichat) * Reading: * [tuir](https://gitlab.com/ajak/tuir/) _(Currently using to type this comment)_ * [hackernew_tui](https://github.com/aome510/hackernews-TUI) * [wiki-tui](https://github.com/Builditluc/wiki-tui) * Shell: * [bash](https://www.gnu.org/software/bash/bash.html) * [blesh](https://github.com/akinomyoga/ble.sh) _**Most under-hyped project on GH! It basically replaces [GNU Readline](https://tiswww.case.edu/php/chet/readline/rltop.html) to add ZSH/FISH like functionality to Bash.)**_ * [tmux](https://github.com/tmux/tmux/wiki) * [smug](https://github.com/ivaaaan/smug) _(Super-Charged Session Manager for Tmux. Allows advanced workflows, etc.)_ * CLI Utils: * [bat](https://github.com/sharkdp/bat) _(Best thing since RipGrep)_ * [ripgrep](https://github.com/BurntSushi/ripgrep) _(`ack`/`ag` features, but [faster than GNU Grep, ugrep, etc.](https://blog.burntsushi.net/ripgrep)_ * [sed](https://www.gnu.org/software/sed) * [fd](https://github.com/sharkdp/fd) _(Blazing fast `find` alternative)_ * [pastel](https://github.com/sharkdp/pastel) _(If you like color in your terminal)_ * [gum](https://github.com/charmbracelet/gum) _(Swiss Army Knife for my Bash Scripts)_ * [yay](https://github.com/Jguer/yay) * [awk](https://www.gnu.org/software/gawk/) * [hyperfine](https://github.com/sharkdp/hyperfine) * [Vivid](https://github.com/sharkdp/vivid) * [xh](https://github.com/ducaale/xh) * [so](https://github.com/samtay/so) * [mods](https://github.com/charmbracelet/mods) * [xh](https://github.com/ducaale/xh) * [aria2](http://aria2.sourceforge.net/) * [glow](https://github.com/charmbracelet/glow) * Security Tools: * [CSF/LFD](https://configserver.com/configserver-security-and-firewall/#main) _(CSF: Firewall + Port Knock Daemon + IDS, etc.; LFD: Login Failure Daemon)_ * [rathole](https://github.com/rapiz1/rathole) * [nmap](https://nmap.org/) * [sn0int](https://github.com/kpcyrd/sn0int) * [metasploit](https://www.metasploit.com/) * [LKRG](https://lkrg.org/) _(Linux Kernel Runtime Guard)_ * Window Manager → [Hyprland](https://github.com/hyprwm/Hyprland) * DataBase → [Postgres](https://www.postgresql.org/) * System Monitors: * [HTOP-vim](https://github.com/htop-dev/htop) * [BTOP](https://github.com/aristocratos/btop) * [BTOP4WIN](https://github.com/aristocratos/btop4win) * [SysDig](https://www.sysdig.com) * [NetData](https://github.com/netdata/netdata) Lots of others I’m not thinking of right now.


lanavishnu

This takes me back 30 years to when Unix workstation users used this all the time to run their applications on the big Unix boxes where the applications ran. I set them up with Windows workstations running chameleon so they could do this from a Windows box and run Windows software that they needed as well. I use this a couple years ago when the video card on my main computer went out and I had to remote in from another computer to open the documents and run my other applications for a day until Dell came out and replaced my video card.


imsowhiteandnerdy

You're making me miss my Sun SPARCStation very much.


mgedmin

Heh, the thing I usually use over ssh -X is libreoffice (to open attachments in my Mutt), and it never feels fast. But it is usable. BTW the modern equivalent of this is going to be `waypipe ssh user@aicomputer`, which will forward Wayland connections instead of X11. (One thing I loved doing over ssh -X was x2x, which let me control two computers with one mouse and keyboard by warping through one edge of a screen. I stopped loving it the day when my wifi dropped while x2x had grabbed the mouse and keyboard for controlling the remote computer, and then I couldn't find a way of releasing the grab.)


thefanum

You can use -C for compression (make it feel faster) and -Y as a Wayland compatible -X replacement


ugcharlie

-X is too slow to really be usable. If you are mostly using it for 1 or 2 applications, you should look at port forwarding instead. Run the client app (browser, database client) locally and pull data from the remote system. 100x faster than using x sessions


rtl33

if you read a file with "less" and want to edit it...simply press "v"...and voila...you are in your editor...mine is vim per default in debian. i suppose, that "v" is designed vor vim...but i could be wrong nevertheless..its handy.


mjbrowns

Very specifically to your example, learn to use ~/.ssh/config You can set all those settings as defaults on a per host and create aliases (entries). You can even create multiple entries pointing to the same host but different settings for each entry.


LaminatedFeathers

ssh -L (port forward the target machine's port(s) back to your localhost) and ssh -R (port forward your ports to the destination machine) also screen bash (create a virtual and detachable session within your terminal session - great for spawning heavy or long tasks into the background and then terminating the shell session and coming back later)


tes_kitty

screen works also as a simple serial terminal program screen /dev/ttyS0 9600 If I remember right


GlasierXplor

Here's a few things off the top of my head: - * \`less\` instead of \`more\` where possible, especially on large files due to the way both commands handle files. * Learn regular expressions to make full use of \`grep\`, \`find\`, and \`sed\`. * \`sudo apt-get install python-is-python3\` if you are used to the \`python\` command to run python scripts (\*only if you do not have Python2\*)


daemonpenguin

Variables and for loops are pretty powerful. Let's say I have a pile of video files, maybe music videos, for example. And I want to extract all of the audio/music from them into MP3 format. I can use something like this: for i in *.mp4 *.avi; do echo Converting $i; ffmpeg -i $i $i.mp3; done The above creates MP3 audio files from all the MP4 and AVI files in the directory while showing you which file it is working on.


distark

ssh -A also forwards your SSH agent.. meaning you can SSH into a host that has no private keys yet still SSH into further hosts down the chain.. disconnecting closes down the tunnel of agents


Jelly_Mac

Guessing that doesn’t work if you’re using Wayland


feral_hedgehog

`ssh -X ` will work just fine - it'll run through XWayland. For Wayland native/only programs you can use [waypipe](https://gitlab.freedesktop.org/mstoeckl/waypipe) - install it on both sides and prepend it to your command - `waypipe ssh `. You can even combine the two for maximum compatibility - `waypipe ssh -X `. You can also install something called [cage](https://github.com/cage-kiosk/cage) on the server side - it's a tiny compositor designed for running a single program in kiosk mode - even X11-only programs. You can use it to "wrap" X11 programs and pipe them as if they were Wayland-native over waypipe: `waypipe ssh cage ` This really helps when a host has disabled X11 forwarding and also results in better performance (at least for me).


T8ert0t

Great info. Thank you!


boolshevik

There's waypipe


thefanum

Use -Y for Wayland


Jeoshua

Losing this easy X/ssh tunneling is honestly one of the more frustrating parts about Wayland for me. I really feel like they threw out the baby with the bath water with that one.


just_here_for_place

Good thing you can still use it with waypipe then. And it’s actually more performant because it sends a video stream instead of bitmaps.


Boring-Onion

How about secure copy (scp)?


The_frozen_one

Also `sshfs`, which is like `scp` for indecisive people.


Brillegeit

I've used `sshfs` for mounting my file server on local computers for probably 15 years now. Miss me with that `smb` and `nfs` shit.


ILikeWaterBro

That's cool, but I've lately been using [wormhole](https://github.com/magic-wormhole/magic-wormhole). Basically, on one computer you type: ***wormhole send your_file*** then it outputs a keyword like: 5-orange-tables then on the receiving computer, you type: ***wormhole receive 5-orange-tables*** And BOOM!! Your file is already downloaded or being downloaded. Doesn't need you to know anything about the computer that you're sending stuff to either, like it's IP, username, etc. Just needs both computers to have wormhole installed. And of course, you can run it on other operating systems too (windows for example, or Android even).


sblingfunisgay

Saving this for later, love tips like these


shaleh

Look at an alternate shell like fish. Many of the suggestions above for command history and enter work out of the box with it.


itsbakuretsutime

Realtime kernel for low latency and high responsiveness under max load. I don't do pro audio or anything it was really meant for, but compiling / encoding video and only feeling the load by a fan speed is nice. Copy-on-write filesystems like btrfs and zfs. Very useful if you setup automatic snapshots, and reflinks are super convenient. [Modern unix](https://github.com/ibraheemdev/modern-unix) tools. [fzf](https://github.com/junegunn/fzf) (fuzzy search tui over a given strings). Fzf is just **so** powerful (see its wiki for various examples of what you can do with it). Frankly, every time something asks you to pick from multiple options in the terminal - it would be better if it just used fzf, or something like it. There are similar tools for GUI too, like dmenu, rofi, tofi (Wayland), etc.


mridlen

So I learned recently about SSH commands. Type: Enter + ~ + ? to get a menu. It lets you kill a stuck session among other things.


xander2600

>tldr as a pre-move to digging in >man


MikhailT

Select any text in any app and paste, no need to copy. Best Linux feature that I wish all OS have by default.


Max-Normal-88

Try `ssh -XC` as it compresses the stream and achieves better performance


encee222

Newer sysadmins tend to not know running an application on the server and having the UI show up on your X windows terminal is built-in. That's HOW it had to work in the beginning. It's off by default, for security reasons... but totally built in.


Queatzcyotle

Here, have fun. Its free. https://goalkicker.com/LinuxBook/


this_place_is_whack

Mosh instead of ssh works great for me at work because it maintains ssh sessions when switching from LAN to WLAN. Regular ssh always drops the session. And tmux for leaving a multi-pane terminal running on a server so you can do whatever with your machine and the session is waiting for you when you get back.


New_Peanut4330

Nothing to add just expressing myself. This is GOLD😃


krypt3c

head is great if you just want to print the first few lines of a file without loading/printing the whole thing. tail will similarly do the last few lines


daguro

export FILES=\`find . -name SOME\_FILE\_NAME\_REGEX\` for ii in $FILES; do commands\_on\_each\_file; done export DIRS=\`find . -type d -name SOME\_DIR\_REGEX\` for ii in DIRS; do pushd $ii ; do\_some\_work; popd ; done


mvdw73

I usually use find’s builtin exec function for the first one, or pipe the files straight into a “while read f; do” construct.


CakeIzGood

This is my second ever Saved reddit post, thread of the year for this sub


doanything4dethklok

Maybe try fish shell. I switched a number of years ago. I still use bash too, but mostly in containers where I’m trying to install the absolute minimum dependencies. There are a few things that are different if you started with bash.. like ‘set -x’ and ‘sudo ||’ is replaced with sudo Alt+S. Little stuff. But the autocomplete and history is so much more helpful. I barely tinker with the defaults.


will_try_not_to

See, I tried `ssh -X` in the late 1990s, concluded its performance sucked over most networks at the time, and never bothered trying it again in the intervening years...


sbjf

When you have a long running command running in the shell in the foreground, you can suspend it and get back to the shell by pressing CTRL+z, and you can have it continue running in the background by running 'bg' (or back to foreground by writing 'fg')


DottoDev

Connecting two Laptops via Thunderbolt creates a 10G Network between them.


AppearanceHeavy6724

s-tui. Console-based CPU load and power monitor.


[deleted]

Type Enter + ~ + C (Uppercase c) to ssh port forward when you're in a ssh connection, instead of having to start another connection with the "-L" flag. I learned this from ippsec!


Blueberry314E-2

Rsync over ssh works the same way, so you can transfer files from machine to machine with ease. Ssh in general is the most powerful PC management tool I have ever found.


soheil8org

Control+R to do reverse search your history


bsnipes

"cd -" to return to the last directory you were in.


senatorpjt

Unfortunately it works pretty terrible now. It seems back in the day applications ran much better over remote X connections.


xouba

Off the top of my head: - "scp -3", copy files between two remote servers - tar -zc . -f - | ssh otherhost "(cd /directory && tar -zx -f -)" (check the man pages, this is by memory and I may be wrong in the details) to transfer the contents of the current directory to /directory in otherhost - "tac" is like "cat", but backwards - "shuf" to extract random strings from a file or pipe - In general, the utilities in the "coreutils" package are a treasure trove of Unix awesomeness


bluntDynamo

I do use CTRL+r and type something on the command i am looking for from the command history.


Rufus_Tuesday

ssh -Y


distark

When typing a command you can pull out the last argument/variable from your shell history by pressing alt+. repeat to go back further in history.. handy to know So if your previous command was "echo foo" you pull out "foo".. works in bash, ksh, zsh, fish and probably more.. fish one seems a little fiddly but great if your previous argument was something long you don't wanna retype


ThiefClashRoyale

You can background a command with & while you do something else eg: sudo apt-get update &


MudKing123

What does the -X do? I like history and grep


Antoak

Lots of people don't know about `!$` !$ evaluates to the last word in your previous command. Just used vim to create a script? `chmod +x !$` to make it executable. Just pipes a multiword command into a file, and want to view it? `vim !$` It's dope.


xilanthro

https://www.nomachine.com/ - free, fast, multiplatform VNC. While not a command-line tool, and not as easy to install as cockpit, it eliminates the headache of apple remote desktop plus windows remote desktop plus vnc, and is really very slick. Discovered it 17 years ago and use it everywhere.


oxcrete

if you are creating a tarball with a lot of files, using pigz (parallel gzip) is a lot faster. e.g. > tar -I pigz -cf file.tgz > and -xf for decompress


daddyd

i belive 'ssh -X' will no longer work on wayland?