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/

638 Comments

  1. Tomi Engdahl says:

    Linux Fu: A Little Bit Of (Network) History Repeating Itself
    https://hackaday.com/2021/04/26/linux-fu-a-little-bit-of-network-history-repeating-itself/

    These days, embedded systems often have networks and that can make them significantly more complex. Networks are usually pretty nondeterministic and there are a variety of oddball conditions. For example, when your public-access pick and place machine gets written up on Hackaday and you suddenly get a 50X surge in traffic, how does your network stack handle it? While there’s no silver bullet for network testing, there are some tricks that can make it easier and one of those is the tcpreplay utilities that allow you to record complex network traffic and then play it back in a variety of ways. This has many benefits, especially if you manage to capture that one thing that triggers bad behavior sporadically. Being able to play it back on demand can speed up diagnostics considerably.

    Reply
  2. Tomi Engdahl says:

    How to Monitor Linux Server and Process Metrics from Browser

    https://www.tecmint.com/monitor-linux-server-in-realtime/

    Reply
  3. Tomi Engdahl says:

    How to Test Your Internet Speed Bidirectionally from Command Line Using ‘Speedtest-CLI’ Tool

    https://www.tecmint.com/check-internet-speed-from-command-line-in-linux/

    Reply
  4. Tomi Engdahl says:

    Linux Fu: Databases Are Next-Level File Systems
    https://hackaday.com/2021/06/08/linux-fu-databases-are-next-level-file-systems/

    It is funny how exotic computer technology eventually either fails or becomes commonplace. At one time, having more than one user on a computer at once was high tech, for example. Then there are things that didn’t catch on widely like vector display or content-addressable memory. The use of mass storage — especially disk drives — in computers, though has become very widespread. But at one time it was an exotic technique and wasn’t nearly as simple as it is today.

    However, I’m surprised that the filesystem as we know it hasn’t changed much over the years. Sure, compared to, say, the 1960s we have a lot better functionality. And we have lots of improvements surrounding speed, encoding, encryption, compression, and so on. But the fundamental nature of how we store and access files in computer programs is stagnant. But it doesn’t have to be. We know of better ways to organize data, but for some reason, most of us don’t use them in our programs. Turns out, though, it is reasonably simple and I’m going to show you how with a toy application that might be the start of a database for the electronic components in my lab.

    You could store a database like this in a comma-delimited file or using something like JSON. But I’m going to use a full-featured SQLite database to avoid having a heavy-weight database server and all the pain that entails. Is it going to replace the database behind the airline reservation system? No. But will it work for most of what you are likely to do? You bet.

    The Right Tool for the Right Job

    Of course, there are limitations. However, if you are rolling your own file format for something, you might want to consider switching to SQLite and handling it as a database. According to the project’s website, doing so may actually save space and increase access speed. Plus, once you get the hang of it, it is just easier. It is also easier to scale later if you decide to switch to a real database.

    The C code will turn out to be the least of our problems. The two things you’ll want to understand most are how to structure the data — the database schema — and how to populate the initial data. Even if you want to have your program add data eventually, it is nice to start with a little data initially to get your program working.

    Reply
  5. Tomi Engdahl says:

    Branch Out Your SQLite Database With LiteTree
    https://hackaday.com/2018/09/02/branch-out-your-sqlite-database-with-litetree/

    Whether you want some quick and dirty data storage, or simply don’t have that heavy requirements for your local database system, SQLite is always a good choice. With its portable single-file approach, bindings to all major languages, and availability on systems of all sizes, it is relatively easy to integrate a SQLite database in your undertakings. And if you tend to develop directly in your production environment, you may be interested to hear that the folks at [aergo] made this a lot more flexible (and interesting) by adding Git-style branching to the SQLite engine.

    Similar to Git, each database operation is now stored as a commit with a unique id as reference point, and new branches will keep track how they diverge from their parent reference point. This essentially lets you modify your data set or database schema on the fly, while keeping your original data not only untouched, but fully isolated and functional. Unfortunately, merging branches is not yet supported, but it is planned for the near future.

    https://github.com/aergoio/litetree

    Reply
  6. Tomi Engdahl says:

    7 ‘dmesg’ Commands for Troubleshooting and Collecting Information of Linux Systems
    https://www.tecmint.com/dmesg-commands/

    Reply
  7. Tomi Engdahl says:

    Identify security properties on Linux using checksec
    Learn how to use checksec to identify an executable’s security properties, understand what they mean, and know how to use them
    https://opensource.com/article/21/6/linux-checksec

    Reply
  8. Tomi Engdahl says:

    Learn more about your Linux system with inxi
    Gather a variety of system and non-system information with a single Linux command: inxi
    https://www.redhat.com/sysadmin/learn-more-inxi

    Reply
  9. Tomi Engdahl says:

    CloudLinux releases UChecker security tool for Linux servers
    CloudLinux, best known for its CentOS work, is releasing UChecker, its Linux server security scanner.
    https://www.zdnet.com/article/cloudlinux-releases-uchecker-security-tool-for-linux-servers/

    Reply
  10. Tomi Engdahl says:

    Coding A Custom Driver For The Adafruit Mini Thermal Printer
    https://hackaday.com/2021/06/26/coding-a-custom-driver-for-the-adafruit-mini-thermal-printer/

    Thermal printers are cool… or, uh, warm actually. They use heat to make images, so they never need ink and they print on receipt rolls. The thermal printer available from Adafruit is a particularly tasty example, as it comes fully documented for the budding hacker. [Ed] is one such person, who set about writing his own driver to use the hardware with Linux on a Raspberry Pi.

    The project came about as [Ed] didn’t like the halftone output from the standard Adafruit CUPS driver. Thus, a dithering-capable driver was needed instead.

    https://deathandthepenguinblog.wordpress.com/2019/12/08/adafruit-mini-thermal-printer-part-1-getting-better-pictures/

    Reply
  11. Tomi Engdahl says:

    Query your Linux operating system like a database
    Use database-style queries to get system information easily.
    https://opensource.com/article/21/6/osquery-linux

    Linux offers a lot of commands to help users gather information about their host operating system: listing files or directories to check attributes; querying to see what packages are installed, processes are running, and services start at boot; or learning about the system’s hardware.

    Each command uses its own output format to list this information. You need to use tools like grep, sed, and awk to filter the results to find specific information. Also, a lot of this information changes frequently, leading to changes in the system’s state.

    It would be helpful to view all of this information formatted like the output of a database SQL query. Imagine that you could query the output of the ps and rpm commands as if you were querying an SQL database table with similar names.
    Fortunately, there is a tool that does just that and much more: Osquery is an open source “SQL powered operating system instrumentation, monitoring, and analytics framework.”

    Many applications that handle security, DevOps, compliance, and inventory management (to name a few) depend upon the core functionalities provided by Osquery at their heart.

    https://osquery.io/

    Reply
  12. Tomi Engdahl says:

    Vim vs. Nano vs. Emacs: Three sysadmins weigh in
    Three editors. Three experts. Which Linux text editor is right for you?
    https://www.redhat.com/sysadmin/3-text-editors-compared

    Reply
  13. Tomi Engdahl says:

    Send and receive Gmail from the Linux command line
    Use Mutt to send and receive email from your terminal, even if you’re using hosted service such as Gmail.
    https://opensource.com/article/21/7/gmail-linux-terminal

    Reply
  14. 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 ip command examples https://www.cyberciti.biz/faq/linux-ip-command-examples-usage-syntax/

    Reply
  15. Tomi Engdahl says:

    Want to find out max supported ram and slots in your linux system without opening up your computer? Try these tips.
    https://www.cyberciti.biz/faq/how-to-find-the-number-of-ram-slots-in-linux/ #linux #sysadmin

    Reply
  16. Tomi Engdahl says:

    You can easily secure communication between the MariaDB server and the client using TLS. Here is how to set up MariaDB TLS/SSL and secure connections from clients https://www.cyberciti.biz/faq/howto-install-configure-mariadb-galera-master-cluster-ubuntulinux/ #Linux #Unix #security #infosec #mysql

    Reply
  17. Tomi Engdahl says:

    Let us see how to install Dart lang on #Debian or #Ubuntu #Linux and configure VIM as Dart IDE with help of various Vim plugins.
    https://www.cyberciti.biz/programming/how-to-install-dart-on-linux-and-configure-vim-as-ide/ #softwaredevelopment

    Reply
  18. Tomi Engdahl says:

    So how do you stream audio from your Apple #iOS or Google #Android phone to your laptop or desktop speakers? Let us see how to set up a Bluetooth speaker to stream audio from your Android / iOS mobile phone to your #Linux based laptop or desktop that got better audio speakers. https://www.cyberciti.biz/mobile-devices/linux-set-up-bluetooth-speaker-to-stream-audio-from-your-android-ios-mobile-phone/

    Reply
  19. Tomi Engdahl says:

    The default signal for kill #Linux or #Unix process is as follows ((In case if you are not sure check https://bash.cyberciti.biz/guide/Sending_signal_to_Processes)

    Reply
  20. Tomi Engdahl says:

    Bash for president :P Do check out Bash scripting wiki tutorial https://bash.cyberciti.biz/guide/Main_Page #Linux #programming #devops

    Reply
  21. Tomi Engdahl says:

    Let us talk about ssh server and client auditing tools that anyone can use to the hardened standard SSH server and client configuration for security issues on your #Linux, FreeBSD, macOS and #Unix boxes https://www.cyberciti.biz/tips/how-to-audit-ssh-server-and-client-config-on-linux-unix.html

    Reply
  22. Tomi Engdahl says:

    Did you know? You can turn off the banner in Linux or Unix using a particular file. When you log in using ssh or other methods, you will find tons of information on the screen. https://www.cyberciti.biz/howto/turn-off-the-login-banner-in-linux-unix-with-hushlogin-file/ #linux #unix

    Reply
  23. Tomi Engdahl says:

    //A quick tutorial about working with systemd targets: Learn how to list, view, and switch between text and GUI targets. Further, learn the difference between SysV init runlevels and systemd targets on Linux distros https://www.cyberciti.biz/faq/switch-boot-target-to-text-gui-in-systemd-linux/ #SysAdmin #linux

    Reply
  24. Tomi Engdahl says:

    Oh wow. I guess this like ignoring bash aliases and functions when running a command:

    alias vnstat=’vnstat -d -i enp0s31f6′ # alias
    vnstat # call alias
    \vnstat -m -i br0 # ignore alias and call real vnstat

    See https://www.cyberciti.biz/faq/ignore-shell-aliases-functions-when-running-command/ for more info. #Linux #Unix #macOS #programming

    Reply
  25. Tomi Engdahl says:

    How to restart systemd without rebooting Linux when critical libraries installed https://www.cyberciti.biz/faq/how-to-restart-systemd-without-rebooting-linux-when-critical-libraries-installed/ #Linux #redhat #Debian #Ubuntu

    Reply
  26. Tomi Engdahl says:

    Filter JSON Data by Value with Linux jq
    https://isc.sans.edu/forums/diary/Filter+JSON+Data+by+Value+with+Linux+jq/27792/
    Since JSON has become more prevalent as a data service, unfortunately, it isn’t at all BASH friendly and manipulating JSON data at the command line with REGEX (i.e. sed, grep, etc.) is cumbersome and difficult to get the output I want. So, there is a Linux tool I use for this, jq is a tool specifically written to manipulate and filter the data I want (i.e. like scripting and extract the output I need) from large JSON file in an output format I can easily read and manipulate.

    Reply
  27. Tomi Engdahl says:

    Some tips on how to colorize grep output for ease of reading with or without shell pipes on your Linux, macOS or Unix-like systems.

    https://www.cyberciti.biz/tips/howto-see-grep-command-output-in-colours.html

    Reply
  28. Tomi Engdahl says:

    Did you know? You can use Linux CLI to find out Windows 10 OEM product key to install and use Win10 using VirtualBox/VMWare or KVM VM under Linux. https://www.cyberciti.biz/faq/linux-find-windows-10-oem-product-key-command/

    Reply

Leave a Comment

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

*

*