Linux / Unix Command Examples

Here are links to some useful Linux tips:

https://www.cyberciti.biz/faq/linux-unix-appleosx-bsd-cat-command-examples/

https://peteris.rocks/blog/htop/

https://www.cyberciti.biz/faq/searching-multiple-words-string-using-grep/

https://www.cyberciti.biz/faq/using-sed-to-delete-empty-lines/

https://www.cyberciti.biz/faq/linux-hide-processes-from-other-users/

https://www.cyberciti.biz/faq/bash-check-if-process-is-running-or-notonlinuxunix/

https://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-bash-assign-variable-command-output/

http://unixmillenniumbug.com/

https://bash.cyberciti.biz/file-management/linux-shell-script-to-reduce-pdf-file-size/

https://www.cyberciti.biz/faq/bash-file-command-not-found-how-to-install-file/

https://www.cyberciti.biz/faq/set-up-a-basic-iptables-firewall-on-amazon-linux-ami/

https://www.cyberciti.biz/faq/fedora-redhat-centos-5-6-disable-firewall/

https://bash.cyberciti.biz/virtualization/shell-script-to-setup-an-lxd-linux-containers-vm-lab-for-testing-purpose/

https://hackertarget.com/ossec-introduction-and-installation-guide/

Awesome. VIM “for people who don’t want to use it , but have to…”. Or see my page https://www.cyberciti.biz/faq/linux-unix-vim-save-and-quit-command/

sudo is the right choice for granting admin rights on the CentOS Linux 8 server. Learn how to create a new user and grant her admin rights https://www.cyberciti.biz/faq/add-create-a-sudo-user-on-centos-linux-8/

643 Comments

  1. Tomi Engdahl says:

    SSH ProxyCommand example: Going through one host to reach another server https://www.cyberciti.biz/faq/linux-unix-ssh-proxycommand-passing-through-one-host-gateway-server/ #Linux #Unix #macOS #SysAdmin #DevOps

    Reply
  2. Tomi Engdahl says:

    Bash is one of the most popular shells for Linux/Unix users and developers. It just got better with a new version that includes enhanced random number generation. Let us take a quick look at new features and learn how to install the latest GNU/BASH 5.1. https://www.cyberciti.biz/linux-news/gnu-bash-5-1-released-with-the-random-srandom-number-engine/

    Reply
  3. Tomi Engdahl says:

    Want to run commands as another user on your Linux desktop or server? Try su, sudo, kpexec, and runuser commands. https://www.cyberciti.biz/open-source/command-line-hacks/linux-run-command-as-different-user/

    Reply
  4. Tomi Engdahl says:

    With its 288 RGB LEDs, this Arduino-controlled cylinder puts on quite the show! https://bit.ly/3gHNtOS

    Reply
  5. Tomi Engdahl says:

    Beginner’s Guide to Analyzing Logs in Linux With journalctl Command
    Beginner’s guide to using journalctl commands for viewing, filtering and analyzing journal logs in Linux.
    https://linuxhandbook.com/journalctl-command/

    Reply
  6. Tomi Engdahl says:

    //Did you know you can colorize and print all IP addresses and interfaces on Linux in a tabular format for better readability?

    ip -br -c addr show
    ip -br -c link show

    See our ip command guide https://www.cyberciti.biz/faq/linux-ip-command-examples-usage-syntax/ pretty cool, huh? #Linux #SysAdmin #devops

    Reply
  7. Tomi Engdahl says:

    //{Updated} In this in-depth tutorial, we will explain to read, list and set environment and shell variables on Linux including read-only and persistent configs. https://www.cyberciti.biz/faq/set-environment-variable-linux/ #sysadmin #Linux #programming

    Reply
  8. Tomi Engdahl says:

    https://www.facebook.com/126000117413375/posts/4137677076245639/

    //Do you want to see a list or find open ports on your server from Linux, macOS, FreeBSD or Unix-like systems when Nmap is not installed? Try netcat/nc command. It is simple yet effective for offensive and defensive purposes. No root access needed:

    nc -w1 -zv your-server-ip 1-1023 2>&1 | grep succeeded

    See https://www.cyberciti.biz/faq/linux-port-scanning/ for more info.

    Reply
  9. Tomi Engdahl says:

    A bash script that will automatically install a list of bug hunting tools that I find interesting for recon, exploitation, etc. (minus burp) For Ubuntu/Debain. Feel free to fork, and add your own tools.
    https://github.com/0xApt/awesome-bbht

    Reply
  10. Tomi Engdahl says:

    //Display http/ftp status code from Linux, macOS and Unix-like systems. Useful to see if a remote website is up or down without using 3rd party service. HTTP/200 means up and running:

    curl -L -o /dev/null -s -I -w ‘%{http_code}\n’ url

    See https://www.cyberciti.biz/faq/curl-hide-progress-bar-output-linux-unix-macos/ for more examples.

    Reply
  11. Tomi Engdahl says:

    // Learn how to configure Intel WiFi on Debian Linux 10 or 11 when you need a binary blob.

    https://www.cyberciti.biz/faq/intel-wifi-on-debian-linux-when-you-get-firmware-failed-to-load-iwlwifi-8265-36-error/ #sysadmi #Debian #Linux

    Reply
  12. Tomi Engdahl says:

    //This page explains how to change/update your LUKS disk encryption passphrase when you initially set a weak passphrase that protects your Linux disk data. Useful for rotating passphrase is also good security practice.
    https://www.cyberciti.biz/security/how-to-change-luks-disk-encryption-passphrase-in-linux/ #Linux #Sysadmin #IT #security

    Reply
  13. Tomi Engdahl says:

    Let us start a flame fest over a text editor: Top six awesome text/CLI editors for Linux, macOS and Unix devs/users. https://www.cyberciti.biz/open-source/awesome-text-editors-for-linux-and-unix-command-line-users-developers/ #programming #UNIX #Linux #SysAdmin #MacOS #bsd

    Reply
  14. Tomi Engdahl says:

    //Rolling back to the previous version may solve the problem or free the disk space. Both CentOS/RHEL support rollback feature, but I learned hard way both Debian and Ubuntu Linux does not support rollback feature yet. https://www.cyberciti.biz/howto/debian-linux/ubuntu-linux-rollback-an-apt-get-upgrade/ #sysadmin

    Reply
  15. Tomi Engdahl says:

    //Ubuntu 20.04 add network bridge (br0) with nmcli command https://www.cyberciti.biz/faq/ubuntu-20-04-add-network-bridge-br0-with-nmcli-command/ #Linux #SysAdmin

    Reply
  16. Tomi Engdahl says:

    Learn how to use tar over ssh for moving files securely, quick backups and more.
    https://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/ #Linux #UNIX #macOS #Sysadmin #devlife

    Reply
  17. Tomi Engdahl says:

    //tuptime – Linux See Historical and Statistical Uptime of System https://www.cyberciti.biz/hardware/howto-see-historical-statistical-uptime-on-linux-server/ Works on both #Linux and #FreeBSD.

    Reply
  18. Tomi Engdahl says:

    //How to issue Let’s Encrypt wildcard certificate with acme.sh and Cloudflare DNS https://www.cyberciti.biz/faq/issue-lets-encrypt-wildcard-certificate-with-acme-sh-and-cloudflare-dns/ Are you using AWS route 53 DNS? See how use Route 53 to get Let’s Encrypt wildcard certificate with acme.sh and DNS auth https://www.cyberciti.biz/faq/route-53-lets-encrypt-wildcard-certificate-with-acme-sh/

    Reply
  19. Tomi Engdahl says:

    Did you know? You can allows processes/services to bind() to non-local IP addresses, which can be quite useful for application such as load balancer such as Nginx, HAProxy, keepalived, WireGuard, OpenVPN and others during boot time on Linux. https://www.cyberciti.biz/faq/linux-bind-ip-that-doesnt-exist-with-net-ipv4-ip_nonlocal_bind/

    Reply
  20. Tomi Engdahl says:

    //perl and egep problem for Linux and Unix users. You may find my Regular expressions in grep ( regex ) with examples handy https://www.cyberciti.biz/faq/grep-regular-expressions/

    Reply
  21. Tomi Engdahl says:

    //Want to see a sorted list of your top 10 directory sizes that is eating your disk space on Linux or FreeBSD/macOS? Try:

    du -sh * | sort -h | tail -10

    See https://www.cyberciti.biz/faq/how-do-i-find-the-largest-filesdirectories-on-a-linuxunixbsd-filesystem/ or other CLI tricks or techniques to find largest top 10 files and directories on your box. #Linux #Unix #macOS #freebsd

    Reply
  22. Tomi Engdahl says:

    //Yet another fancy and fantastic looking tool called duf to display statistics on free disk space in Unix, Linux, macOS, *BSD, Android, and Windows written in Golang.https://www.cyberciti.biz/open-source/command-line-hacks/duf-disk-usage-free-utility-for-linux-bsd-macos-windows/ #Linux #macOS #unix

    Reply
  23. Tomi Engdahl says:

    //Let us see how to improve your bash/sh/ksh/dash shell script with ShellCheck lint script analysis tool on Linux or FreeBSD unix system https://www.cyberciti.biz/faq/how-to-install-shellcheck-on-freebsd-to-analysis-scripts/

    Reply
  24. Tomi Engdahl says:

    8 tips for the Linux command line
    Take advantage of all of the powers the almighty Linux command line has to offer.
    https://opensource.com/article/21/1/linux-commands

    Reply
  25. Tomi Engdahl says:

    //Bash is usually the default shell on Linux desktop and used be default on macOS too. Here are useful keyboard shortcuts. More at https://bash.cyberciti.biz/guide/Main_Page

    Reply
  26. Tomi Engdahl says:

    FYI, we can keep SSH connection alive when OpenSSH server drops you out after few minutes of inactivity https://www.cyberciti.biz/tips/open-ssh-server-connection-drops-out-after-few-or-n-minutes-of-inactivity.html

    Reply
  27. Tomi Engdahl says:

    Mosh (mobile shell): Remote terminal application that allows roaming, supports intermittent connectivity and provides intelligent local echo and line editing of user keystrokes.

    Mosh is a replacement for interactive SSH terminals. It’s more robust and responsive, especially over Wi-
    Fi, cellular, and long-distance links.

    Mosh is free software, available for GNU/Linux, BSD, macOS, Solaris, Android, Chrome, and iOS.

    https://mosh.org/

    Reply
  28. Tomi Engdahl says:

    Some Linux distros and even different kernel versions within a distro have disabled IRQ time accounting. In such case, your monitoring tools will report zero time spent in hardware interrupt handlers (shown as %hi, %irq, hiq, etc). It’s easy to check how your kernel is behaving by looking at /proc/stat and you can still measure interrupt CPU usage using perf and a little creativity.

    Is Your Linux Version Hiding Interrupt CPU Usage From You?
    https://tanelpoder.com/posts/linux-hiding-interrupt-cpu-usage/

    Reply
  29. Tomi Engdahl says:

    Suraj Kushwah’s Google-Powered Tuxi Is Like an Alexa, Cortana, or Siri for Your Terminal Window
    Tuxi the text-based assistant takes your natural language queries at the terminal and answers them using Google’s in-results infoboxes.
    https://www.hackster.io/news/suraj-kushwah-s-google-powered-tuxi-is-like-an-alexa-cortana-or-siri-for-your-terminal-window-f44ae121f52e

    Reply
  30. Tomi Engdahl says:

    Linux Fu: Shell Script File Embedding
    https://hackaday.com/2021/04/09/linux-fu-shell-script-file-embedding/

    You need to package up a bunch of files, send them somewhere, and do something with them at the destination. It isn’t an uncommon scenario. The obvious answer is to create an archive — a zip or tar file, maybe — and include a shell script that you have to tell the user to run after unpacking.

    That may be obvious, but it assumes a lot on the part of the remote user.

    They need to know how to unpack the file and they also need to know to run your magic script of commands after the unpack. However, you can easily create a shell script that contains a file — even an archive of many files — and then retrieve the file and act on it at run time. This is much simpler from the remote user’s point of view. You get one file, you execute it, and you are done.

    In theory, this isn’t that hard to do, but there are a lot of details. Shell scripts are not compiled — at least, not typically — so the shell only reads what it needs to do the work. That means if your script is careful to exit, you can add as much “garbage” to the end of it as you like. The shell will never look at it, so it’s possible to store the payload there.

    Script Doctor

    While bash scripting is often maligned and not without reason, it is very flexible and powerful, as this example shows. It is dead easy to embed files in a script and that opens up a lot of flexible options for distributing complex file setups and applications.

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

*

*