Every team has that one person. You know the one. They type eight characters, hit enter, and suddenly the port conflict is fixed, the file is found, and the server is running — all while you were still reading the error message.
Here's the secret: they're not wizards. They just know a handful of commands that solve the problems you hit every single day. I've collected seven of them. None require installing anything. All of them will make a junior dev watching your screen quietly assume you have root access to the universe.
(Windows folks: everything here works in WSL or Git Bash.)
1. Ctrl+R — search your command history
You ran a long, clever command two weeks ago. It's gone from your memory but not from your shell.
Press Ctrl+R and start typing any part of it — docker, ssh, that weird find invocation — and your shell will find it as you type. Press Enter to run it, or the right arrow to edit it first.
Technically a shortcut, not a command, but it's the single highest-value thing on this list. I use it roughly 40 times a day.
2. sudo !! — rerun the last command, but properly
$ cat /var/log/syslog
Permission denied
$ sudo !!
!! expands to the previous command. So sudo !! means "run that again, but with the permissions I clearly needed the first time."
The two seconds of smugness this buys you is worth more than the entire article.
3. cd - — jump back to the previous directory
You cd'd into a deeply nested folder, and now you need the one you just came from. Don't retype the path. Don't cd ../...
$ cd -
It's the terminal's "back" button. Pair it with cd (no arguments, jumps home) and you can navigate for a whole day without typing a full path.
4. lsof -i :3000 — find out who's squatting on your port
The classic: EADDRINUSE: address already in use :3000. Something is already running on your port. Something you started 40 minutes ago and forgot.
$ lsof -i :3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 41293 you 23u IPv4 ... TCP *:3000 (LISTEN)
$ kill -9 41293
Find the PID, kill it, restart your server. This one command has probably saved me more cumulative time than any other on this list. It's the difference between "why won't it start" for 15 minutes and 10 seconds of smug typing.
5. tree -L 2 — see the shape of a project
New repo, 47 directories, no idea where anything lives.
$ tree -L 2
Two levels of the whole project structure, in one screen. Bump it to -L 3 when you need more depth. (It's often not installed by default — brew install tree or apt install tree, one time, done.)
6. watch -n 2 <command> — a command that refreshes itself
Waiting for a file to appear, a build to finish, a GPU to free up? Instead of re-running the command manually every few seconds:
$ watch -n 2 ls -la dist/
It re-runs ls every 2 seconds, in place, and highlights what changed. You just watch. It's a poor man's dashboard and it's glorious.
7. tee — see the output AND keep it
You run a command, it prints 200 lines of something important, and it's gone. You needed that in a file.
$ ./build.sh 2>&1 | tee build.log
tee passes the output to your screen and writes it to build.log at the same time. No more "wait, run that again and pipe it somewhere" — the somewhere is built in.
The real trick
Notice what all seven have in common: none of them are impressive in isolation. They're all things you could do "the long way" in a minute or two.
That's exactly why they read as wizardry. When someone sees you type sudo !! and the problem evaporates, they don't see the 200 times you did it manually before. They just see the fix.
Learn one of these per week. In two months you'll be the person on the team that juniors watch suspiciously.
Top comments (0)