Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Useful Terminal Commands.
#1
Over the last two years I've collected some very useful Commands that I’d like
to share...that you can run in the Terminal...these Commands will not harm
your System...please feel free to add more.

Graphics card Information...   inxi -SGxx

CPU Info...   lscpu

What OS are you using...  inxi -S

Mint desktop environment...  inxi -Szxx

Firewall Status...   sudo ufw status verbose

How much HDD space is available?     inxi -po

If you'd like to free up drive space, a useful and safe command
is...  sudo apt-get clean

Hard drive Info...type...  lsblk

This terminal command will show your Ram hardware and
configuration...   sudo inxi -m

Version of Linux Mint...  inxi -Sz

CPU Usage...  cpufreq-info 

Hard Drive Temp...  sudo hddtemp /dev/sd?

Computer Information...   inxi -Fxzd   
  
  Core Temperatures type in Terminal...   sensors

System info...   sudo lshw > lshw.txt

Graphics card Information...   inxi -Sgxx

Show DNS Being Used...  sudo nmcli dev show | grep DNS

Flush DNS in Linux Mint...   sudo /etc/init.d/dns-clean start

How Much Ram do I Have...   free -m

What Kernel Version Do I Have...   uname -r

What Wine Version... wine --version
Linux Forever...Windoze Never
Reply
#2
Great post!!! Added to my cheat sheet.
Reply
#3
Some useful things I sometimes use:
Code:
nmcli dev                # show status of network devices
nmcli dev wifi         # show nearby WiFi networks
xrandr -q                 # show information and possible resolutions for every connected screen
acpi                          # battery status (add '-i' flag for battery health)
pgrep [program]   # find running instances of [program]
binwalk [file]          # find hidden files insede binary files (like ZIP archives hidden in a PNG image)
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#4
(09-02-2018, 02:13 AM)bob777 Wrote: Over the last two years I've collected some very useful Commands that I’d like
to share...that you can run in the Terminal...these Commands will not harm
your System...please feel free to add more.

Graphics card Information...   inxi -SGxx

CPU Info...   lscpu

What OS are you using...  inxi -S

Mint desktop environment...  inxi -Szxx

Firewall Status...   sudo ufw status verbose

How much HDD space is available?     inxi -po

If you'd like to free up drive space, a useful and safe command
is...  sudo apt-get clean

Hard drive Info...type...  lsblk

This terminal command will show your Ram hardware and
configuration...   sudo inxi -m

Version of Linux Mint...  inxi -Sz

CPU Usage...  cpufreq-info 

Hard Drive Temp...  sudo hddtemp /dev/sd?

Computer Information...   inxi -Fxzd   
  
  Core Temperatures type in Terminal...   sensors

System info...   sudo lshw > lshw.txt

Graphics card Information...   inxi -Sgxx

Show DNS Being Used...  sudo nmcli dev show | grep DNS

Flush DNS in Linux Mint...   sudo /etc/init.d/dns-clean start

How Much Ram do I Have...   free -m

What Kernel Version Do I Have...   uname -r

What Wine Version...     wine  --version

Thanks for the tips. I will use them often I am sure... (Grin)
**********************************************************
Taglines of the Day:
Today is the tomorrow you worried about yesterday.  Huh 

Everybody remember where we parked. - Kirk

To Boldly Go Where No BBS Has Gone Before. USS Stargazer BBS, Sheridan In.
Reply
#5
(09-02-2018, 02:13 AM)bob777 Wrote: Over the last two years I've collected some very useful Commands that I’d like
to share...that you can run in the Terminal...these Commands will not harm
your System...please feel free to add more.

Graphics card Information...   inxi -SGxx

CPU Info...   lscpu

What OS are you using...  inxi -S

Computer Information...   inxi -Fxzd   

System info...   sudo lshw > lshw.txt

How Much Ram do I Have...   free -m

What Kernel Version Do I Have...   uname -r
Great post bob777! There's some of these I'l definitely notate and use going forward, and there's some that I already use a different variation of. 

*** A quick heads-up; many Distros (to my dismay) do not come with inxi out of the box. For any Ubuntu based Distro, first run $ sudo apt install inxi -yy ***

Examples of what I use that are similar to some of the above I quoted:
$ inxi -F
$ inxi -F |less
$ inxi -F > inxi.txt
(Be sure to use a CAPITAL "F" - it makes a difference)
--- I like to use this because it shows me EVERYTHING! The CPU, GPU, RAM, System, the whole nine yards. Granted some people may like smaller chunks, but I prefer this [one] command to view everything I want to know at one time

$ uname -a
--- More verbose than uname -r is all; again shows a bit more info

$ free -h
$ free -m
$ free -g
--- All essentially do the same thing, but I've gotten used to using -h [human readable] because if there are <1GB it auto-magically shows MB's, and if >1GB it shows the amount in GB's

A couple extras which are add-ons to commands:
-yy
&&

Anytime I run updates, install programs via terminal, and so on, I've gotten to always adding "-yy" after the command; Yes, some say "that's risky" because it tells the system to enter "YES" to any prompts that would normally come up, however, I make sure I know what I'm intending to install ahead of time. If it's something new that's I've never installed on a specific Distro before, or something I've never installed before at all, then I forego that part of the command. Otherwise, it's a nice time-saver to only have to enter in one command.

EXAMPLE: sudo apt dist-upgrade -yy


Whenever I install updates, or need to run multiple commands (FYI this is not needed for multiple program installs in-line), I use "&&" in between the commands. 

EXAMPLE: sudo apt update && sudo apt dist-upgrade -yy
--- This isn't needed for programs, as a user can simply space the programs out:$ sudo apt install inxi htop 


There's more of course, and I'm by NO means super-advanced, but I can finally hold my own with many commands from memory, vs just a year ago having to pretty much check the man page or web search everything. 

Cheers!
Human Being
---
Linux
Is
For
Everyone
Reply
#6
(09-26-2018, 04:34 PM)LIFE.LinuxIsForEveryone Wrote: Whenever I install updates, or need to run multiple commands (FYI this is not needed for multiple program installs in-line), I use "&&" in between the commands. 

EXAMPLE: sudo apt update && sudo apt dist-upgrade -yy
--- This isn't needed for programs, as a user can simply space the programs out:$ sudo apt install inxi htop 
Cheers!

I want to expand on that because this little trick is extremely useful but can also cause some headache.

Imagine you have the folloing:
Code:
command1 && command2

command2 will only be executed if command1 ran succesful, i.e. has an exit value of 0.
If command1 encounters an error (has an exit value above 0), command2 will not be run.

you can simulate that with the folloing:
Code:
false && echo "foo"

Now comes the interesting part: You can use || instead of && to run command2 only when command1 fails:
Code:
false || echo "foo"    # "foo" will be displayed
true || echo "foo"    # "foo" will not be displayed

You can also combine both into a one-line if-else-statement
Code:
command1 && command2 || command3

If command1 is succesful, command2 will be executed, if command1 was not succesful, command3 will be executed.

Code:
true && echo "foo" || echo "bar"    # "foo" will be displayed
false && echo "foo" || echo "bar"    # "bar" will be displayed


If you want to run multiple commands and don't want the entire thing to stop when one command encounters an error, use ';':
Code:
echo "foo"; echo "bar"
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#7
(09-26-2018, 07:31 PM)leon.p Wrote:
(09-26-2018, 04:34 PM)LIFE.LinuxIsForEveryone Wrote: Whenever I install updates, or need to run multiple commands (FYI this is not needed for multiple program installs in-line), I use "&&" in between the commands. 

EXAMPLE: sudo apt update && sudo apt dist-upgrade -yy
--- This isn't needed for programs, as a user can simply space the programs out:$ sudo apt install inxi htop 
Cheers!

I want to expand on that because this little trick is extremely useful but can also cause some headache.

Imagine you have the folloing:
Code:
command1 && command2

command2 will only be executed if command1 ran succesful, i.e. has an exit value of 0.
If command1 encounters an error (has an exit value above 0), command2 will not be run.

you can simulate that with the folloing:
Code:
false && echo "foo"

Now comes the interesting part: You can use || instead of && to run command2 only when command1 fails:
Code:
false || echo "foo"    # "foo" will be displayed
true || echo "foo"    # "foo" will not be displayed

You can also combine both into a one-line if-else-statement
Code:
command1 && command2 || command3

If command1 is succesful, command2 will be executed, if command1 was not succesful, command3 will be executed.

Code:
true && echo "foo" || echo "bar"    # "foo" will be displayed
false && echo "foo" || echo "bar"    # "bar" will be displayed


If you want to run multiple commands and don't want the entire thing to stop when one command encounters an error, use ';':
Code:
echo "foo"; echo "bar"

Noice! As Johnny Carson used to say "Well, uh, I did not KNOW that" Smile

I know a decent amount of terminal commands, but my use is somewhat limited thus far (only been 2.5 years) that to be honest I've never used "&&" and had it fail. So again, thanks for expanding in-depth with all of that. That's all FANTASTIC information to know, for me & everyone reading this thread.

This is one of the multitude of reasons that Linux is so fun for me - I absolutely LOVE learning new & more-proper ways to use the terminal, and learning more and more commands as I go. Plus, learning how to _properly_ use specific commands as well, which  I may have been slightly foggy about previously. But I honestly had no idea regarding the double pipes, etc. Exclamation

Also one additional simple yet useful command I forgot to add near "uname -a" is:
$lsb_release -a
---Gives you all of the pertinent info regarding the (Distro)
  1. Distributor ID
  2. Description
  3. Release
  4. Codename
Cheers!
Human Being
---
Linux
Is
For
Everyone
Reply
#8
Good post, I like these because I always come across a command or two that I've either forgot about or didn't know about.

I'll add a few commands to the list that have served me well over the years:

- To edit GRUB file (16.04/Mint 18x) Very useful for kernel edits/splashcreen edits/plymouth edits/SSD edits. Substitute gedit with whatever text editor you use.

sudo gedit /etc/default/grub


- Filter out private info from lshw command using:

sudo lshw-sanitize


- Trouble installing a program with dependencies, use this command: it checks for and install the required dependencies

sudo apt-get install -f


- Remove unneeded leftover residual files - I run this after kernel swaps normally

sudo apt-get autoremove


- If you install a bunch of stuff using PPA's and want an easy method of deleting them: for example, removing "someppa"

Code:
sudo add-apt-repository --remove ppa:someppa/ppa


- Search for and install updates without input use this command:

sudo apt-get update && sudo apt upgrade -y


- Having trouble with net man or doing some editing and need the edits to appear, then run this command:

sudo service NetworkManager restart


- VPN's are hugely popular these days. If your distro doesn't come packaged with it then install OpenVPN

sudo apt-get install network-manager-openvpn-gnome

These are a few basic commands that maybe someone will find useful.

Have fun
Reply
#9
Some useful commands aliases:

Code:
path='echo $PATH | sed "s,:,\n,g"

This turns the $PATH environment variable (list of directories the shell will look for commands, separated by colons) in something more readable by replacing the colons with newlines.

Code:
ds='df -hHT --exclude-type=tmpfs --exclude-type=devtmpfs'

df gives you all disk space used on each of your drives. My system has a lot of tmpfs and devtmpfs, so this command with exclude those elements and format it
Currently running: NixOS on a desktop (not for newbies!) and Ubuntu MATE on a laptop.
Reply
#10
echo $PATH | sed "s,:,\n,g" works in terminal but not when assigned to an alias
had to remove the single quote in front of echo

what am I missing ?

btw I used
alias path=echo $PATH | sed "s,:,\n,g"
Dos 3.2 to Win 10.
Main - Cinnamon 19.2
   Resistance Is Not Futile!
       It's voltage divided by current
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)