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:

    Beam Your Program To Another Computer
    https://hackaday.com/2020/04/28/beam-your-program-to-another-computer/

    If you’ve programmed much in Linux or Unix, you’ve probably run into the fork system call. A call to fork causes your existing process — everything about it — to suddenly split into two complete copies. But they run on the same CPU. [Tristan Hume] had an idea. He wanted to have a call, telefork, that would create the copy on a different machine in a Linux cluster. He couldn’t let the idea go, so he finally wrote the code to do it himself.

    https://thume.ca/2020/04/18/telefork-forking-a-process-onto-a-different-computer/

    DMTCP (Distributed MultiThreaded Checkpointing) transparently checkpoints a single-host or distributed computation in user-space — with no modifications to user code or to the O/S. It works on most Linux applications, including Python, Matlab, R, GUI desktops, MPI, etc. It is robust and widely used (on Sourceforge since 2007).
    http://dmtcp.sourceforge.net/

    Reply
  2. Tomi Engdahl says:

    Find and delete log files older than 90 days on Linux or Unix:
    find /app/logs/ -name “*.log” -type f -mtime +90 -ls # list it

    Now delete it:
    find /app/logs/ -name “*.log” -type f -mtime +90 -delete

    Reply
  3. Tomi Engdahl says:

    What’s The Deal With Snap Packages?
    https://hackaday.com/2020/06/24/whats-the-deal-with-snap-packages/

    Who would have thought that software packaging software would cause such a hubbub? But such is the case with snap. Developed by Canonical as a faster and easier way to get the latest versions of software installed on Ubuntu systems, the software has ended up starting a fiery debate in the larger Linux community. For the more casual user, nap is just a way to get the software they want as quickly as possible. But for users concerned with the ideology of free and open source software, it’s seen a dangerous step towards the types of proprietary “walled gardens” that may have drove them to Linux in the first place.

    Reply
  4. Tomi Engdahl says:

    How to Install Snapcraft on Ubuntu/CentOS
    https://www.liquidweb.com/kb/how-to-install-snapcraft-on-ubuntu-centos/

    What is Snapcraft?

    Snapcraft is a command-line utility for building snaps. This software allows users to build their own applications or software packages, and then publish them to the Snap store to be shared and utilized by other users! In this tutorial, we will learn how to install Snapcraft on Ubuntu and CentOS.

    What is Snap?

    Snap, also known as Snappy, is a popular package management system for Linux that provides access to self-contained packages called snaps. The thing that sets Snap apart from other package management systems like yum or apt-get is that it isn’t specific to just one Linux distribution. Yum, for example, is the default package manager for Fedora, CentOS, and Redhat, but distributions like Ubuntu and Debian use apt-get as the default package manager. Snap packages work on both Debian and RHEL based distributions because Snap encapsulates its own dependencies.

    Pre-flight Check

    CentOS requires access to the EPEL package repository to install snapd, which is a prerequisite to installing Snapcraft. Here is a tutorial on how to set up the epel repository.
    These instructions are being performed on CentOS 7 and Ubuntu 18.04 LTS servers, respectively.
    Ensure you are logged into these servers as the root user.

    Reply
  5. Tomi Engdahl says:

    If you’re a Linux user, then you may find this kinda cool!

    Someone registered the domain ‘cheat.sh’ and made it a cheatsheet system for Linux. You can access it with a browser, but If you access it with curl from the command line the server detect that will respond with a colorized text-based cheatsheet for your terminal. They put various commands and programming cheatsheets under dirs (example: cheat.sh/find would give you a cheat sheet on the find command.)

    Server code is available on GitHub as well:
    https://github.com/chubin/cheat.sh

    Brilliant project and use of that domain in my opinion!

    Reply
  6. Tomi Engdahl says:

    Learn tips and tricks to exclude files when using the scp and rsync command on your Linux/macOS/*BSD or Unix-like desktop.

    https://www.cyberciti.biz/faq/scp-exclude-files-when-using-command-recursively-on-unix-linux/

    Reply
  7. Tomi Engdahl says:

    Getting notified when tasks complete or failed is essential to avoid service down. So today will explain how developers and sysadmin can send push notifications to their phones powered by iOS or Android from a Linux/Unix shell prompt or scripts. https://www.cyberciti.biz/mobile-devices/android/how-to-push-send-message-to-ios-and-android-from-linux-cli/

    Reply
  8. Tomi Engdahl says:

    Are you looking to gain a bit of performance and speed out of your NGINX web server? Try enablin gzip option on fly to compress responses. See how to enable and use gzip compression with Nginx web server https://www.cyberciti.biz/faq/how-to-enable-the-gzipdeflate-in-nginx-server-on-linux-or-unix-system/

    Reply
  9. Tomi Engdahl says:

    The Linux Mint project has made good on previous threats to actively prevent Ubuntu Snap packages from being installed through the APT package-management system without the user’s consent. This move is the result of “major worries” from Linux Mint on Snap’s impact with regard to user choice and software freedom.

    Linux Mint drops Ubuntu Snap packages
    https://lwn.net/SubscriberLink/825005/6440c82feb745bbe/

    Reply
  10. Tomi Engdahl says:

    Want to rename multiple files at Linux or macos/unix shell? Try these tips
    https://www.cyberciti.biz/tips/renaming-multiple-files-at-a-shell-prompt.html #sysadmin #opensource

    Reply
  11. Tomi Engdahl says:

    Do you want to display a super cool logo of your Linux/Unix distribution along with basic hardware information? Look no further try awesome screenfetch & linux_logo utilities to display logo with hardware configuration on screen. https://www.cyberciti.biz/open-source/command-line-hacks/howto-display-linux-logo-in-bash-terminal-using-screenfetch-linux_logo/ #macos #opensource #linux

    Reply
  12. Tomi Engdahl says:

    Here is a quick guide download/get source code of package using the apt command on Debian or Ubuntu Linux. Sysadmins/developers can apply a custom patch or add/remove the feature and rebuild it.DEB file as per our needs. https://www.cyberciti.biz/faq/how-to-get-source-code-of-package-using-the-apt-command-on-debian-or-ubuntu/ #OpenSource

    Reply
  13. Tomi Engdahl says:

    {Updated} Let us see various commands for Linux to check memory usage.
    https://www.cyberciti.biz/faq/linux-check-memory-usage/

    Reply
  14. Tomi Engdahl says:

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

    This Unix geek is more than socially awkward.

    He’s socially perlward.

    Get with the times. They are socially Ansibleward

    This comment was just waiting to be sed.

    Reply
  15. Tomi Engdahl says:

    10 Linux commands to know the system
    https://www.cyberciti.biz/open-source/linux-commands-to-know-the-system/ #opensource Let me know if you found this useful here or in the comment section itself :)

    Reply
  16. Tomi Engdahl says:

    JavaScript Evaluator for Shell Scripts: Basho lets you to write complex shell tasks using plain JavaScript. It mixes well with shell commands and scripts; so you can choose the best tool for the job. https://bashojs.org/

    Reply
  17. Tomi Engdahl says:

    { Updated } In this quick blog post, we will see how to list and delete all iptables firewall rules using the command line options.
    https://www.cyberciti.biz/tips/linux-iptables-how-to-flush-all-rules.html #OpenSource #Linux #Sysadmin #IT

    Reply
  18. Tomi Engdahl says:

    Linux Check Ram Speed and Type Commands: Learn how to check RAM speed and type (line DDR or DDR2 or DDR3 or DDR4) using the CLI https://www.cyberciti.biz/faq/check-ram-speed-linux/

    Reply
  19. Tomi Engdahl says:

    My top and frequently used git commands from shell history in sorted order:

    git add
    git clone
    git commit
    git pull
    git push
    git reset
    git rm
    git status

    There is also xkcd https://xkcd.com/1597/

    Reply
  20. Tomi Engdahl says:

    https://gitlab.com/remigirard28/MollyEskam-Linux

    Installing this distribution will transform your computer into a website (with SSL) that can be published on the internet (www.mollyeskam.net as default template).

    Reply
  21. Tomi Engdahl says:

    {Updated} Linux Show All Members of a Group Command https://www.cyberciti.biz/faq/linux-list-all-members-of-a-group/ #sysadmin #opensource #linux #sysadmin

    Reply
  22. Tomi Engdahl says:

    Remember boothole bug in grub and other packages that bricked servers? Here is how to hold back packages (blacklist) on an Ubuntu / Debian Linux to prevent updating of a specific package or version. https://www.cyberciti.biz/faq/apt-get-hold-back-packages-command/ #sysadmin #linux #OpenSource

    Reply
  23. Tomi Engdahl says:

    Explains how to pass a parameter/value to a Bash function, including listing and deleting user-defined functions. https://bash.cyberciti.biz/guide/Pass_arguments_into_a_function

    Reply
  24. Tomi Engdahl says:

    Learn how to configure Ubuntu 20.4 LTS server and add a network bridge (br0) with the nmcli command https://www.cyberciti.biz/faq/ubuntu-20-04-add-network-bridge-br0-with-nmcli-command/ #sysadmin #opensource

    Reply
  25. Tomi Engdahl says:

    This in-depth tutorial provides instructions on how to install and configure KVM on Ubuntu 20.04 LTS headless Linux server, including setting up your first VM. https://www.cyberciti.biz/faq/how-to-install-kvm-on-ubuntu-20-04-lts-headless-server/ #sysadmin #IT #OpenSource

    Reply
  26. Tomi Engdahl says:

    bashtop – Awesome Linux resource monitor that shows usage and stats for processor, memory, disks, and network
    https://www.cyberciti.biz/open-source/command-line-hacks/bashtop-awesome-linux-resource-monitor-tool/

    Reply
  27. Tomi Engdahl says:

    {Updated} How to check the file size in Linux/Unix bash shell scripting https://www.cyberciti.biz/faq/howto-bash-check-file-size-in-linux-unix-scripting/ #opensource

    Reply
  28. Tomi Engdahl says:

    Linux Fu: Remote Execution Made Easy
    https://hackaday.com/2020/08/11/linux-fu-remote-execution-made-easy/

    If you have SSH and a few other tools set up, it is pretty easy to log into another machine and run a few programs. This could be handy when you are using a machine that might not have a lot of memory or processing power and you have access to a bigger machine somewhere on the network.

    However, there are a few problems with that scenario. First, you might not have the software on the remote machine. Even if you do, it might not be the version you expect or have all the same configuration as your local copy. Then there’s the file problem. the input file should come from your local file system and you’d like the output to wind up there, too. These aren’t insurmountable, of course. You could install the program on the remote box and copy your files back and forth manually. Or you can use Outrun.

    There are a few limitations, though. You do need Outrun on both machines and both machines have to have the same CPU architecture. Sadly, that means you can’t use this to easily run jobs on your x86-64 PC from a Raspberry Pi. You’ll need root access to the remote machine, too. The system also depends on having the FUSE file system libraries set up.

    A Complex Implementation

    How does this work? A FUSE file system mounts your local filesystem remotely using a lightweight RPC file system. Then a chroot makes the remote machine look just like your local machine but — presumably — faster. There are a few other things done, such as setting up the environment and current directory.

    The chroot, by the way, is why you need root on the remote machine. As an ordinary user, you can’t pivot the root file system to make this trick work.

    To improve performance, Outrun caches system directories and assumes they won’t change over the life of the command. It also aggressively prefetches using some heuristics to guess what files you’ll need in addition to the one that the system asked for.

    Then again, you could do something like this pretty easily with sshfs and some other tricks. If you want to run a program on a bunch of remote machines, there are ways to do that, too.

    https://github.com/Overv/outrun

    Reply
  29. Tomi Engdahl says:

    Quick tip: How to use find command to exclude/ignore files (e.g. Ignore all hidden .dot files while using find command )

    https://www.cyberciti.biz/faq/find-command-exclude-ignore-files/

    #Linux

    Reply
  30. Tomi Engdahl says:

    Let us find out why is it a good idea to use #!/usr/bin/env bash instead of #!/bin/bash as shebang? https://www.cyberciti.biz/tips/finding-bash-perl-python-portably-using-env.html #Linux #Unix

    Reply
  31. Tomi Engdahl says:

    Let us see how to add or subtract N days from the given/current date on Linux, macOS and FreeBSD Unix system.

    https://www.cyberciti.biz/faq/how-to-add-days-to-date-and-get-new-date-on-linux/

    Reply
  32. Tomi Engdahl says:

    Learn how to ignore bash aliases or functions when running a command without removing alias or function from memory or current shell session on a Linux, macOS, or Unix-like systems.

    https://www.cyberciti.biz/faq/ignore-shell-aliases-functions-when-running-command/

    #opensource

    Reply

Leave a Comment

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

*

*