[LINUX HOW-TO] Usefull terminal commands !

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
The-Boxhead Offline
Member+
Posts: 943
Joined: May 2005
Reputation: 17
Location: Norway
Post: #11
@Malard and Spiff:

Thanks for your input. Yes offcourse my references to home dir
as simply /home is wrong. I have now fixed this.
I have also removed sudo from many command examples since
they are not needed and is prolly abuse, yes Wink

Thanks for you input guys, much appreciated. I am not a linux expert
so getting input from experienced user are very valuable !

If anyone still thinks my post contain errors or breaks linux best practice rules
please inform me and i will try to fix it !

PointOfView Nvidia ION Atom 330 - TRANSCEND 2GB DDR2 DIMM 800MHz - G.SKILL 64GB SSD 2.5
Open Elec Beta4 1.95.4
XBMC Online Manual - HOW-TO post about a problem in a useful manner - Create/View Bug Report
Setup/Fix correct resolution on XBMC/Ubuntu - Usefull linux terminal commands
find quote
X3lectric Offline
Closed Account
Posts: 1,756
Joined: Feb 2006
Location: in a Dropbox
Star  some helpful terminal commands to know when learning Linux Post: #12
This has been one of my most difficult problems, when writing how-tos its exactly not to tempt the "idiot" gene... a Impossible task for anyone, this is because the more and better you try, nature comes up and makes a better "idiot".

So having said that you posted...

Code:
sudo apt-get dist-upgrade
Invariably upgrading a distro breaks something, this tempts the "idiot" gene a great deal, this command should come with a BIG disclaimer and or warning. This considering some % of users will have XBMC installed and alsa and lirc...IDK just my point of view.

Another thing is the command to run xbmc-live or stop xbmc-live
Code:
sudo start xbmc-live or sudo stop xbmc-live
also works. Because I run as root for admin/maintenace compile/install purposes basically because "I hate entering sudo", sudo may be redundant on these idk. Honestly these dont work for me without sudo or being root. But everything works OK XBMC wise and as expected.

I have a few commands that I found invaluable and thought sharing would help your list... here's is what I rustled up in my insanity.

If having lm-sensors installed you need to configure it and get results...
Code:
sensors-detect
This goes through the detections of supported sensors and drivers used on your system and file writes to file, requires some user input.
Code:
sensors
Displays the temperatures of all devices detected by sensors-detect
Code:
sensors -s
After any modification to sensors config file this enables new configuration. Can be run before or after the sensors command...
Code:
sudo modprobe "driver"
This temporarily loads a driver or kernel module into current session for e.g. ic2-dev
Code:
echo "driver" >> /etc/modules
Inserts driver or kernel module so it is loaded after reboot automatically.
Code:
sudo dkms add -m driver-name-src -v 1.0.0-ubuntu
Add a drivers source and version into dkms tree (helpfull to have it build automatically after a kernel upgrade. 1 0f 3
Code:
sudo dkms build -m driver-name-src -v 1.0.0-ubuntu
Part of previous only this builds the driver source so it becomes ready to be installed. 2 of 3
Code:
sudo dkms install -m driver-name-src -v 1.0.0-ubuntu
Again part of previous this one actually installs driver and makes it immediately available. 3 of 3
Code:
lsmod
Show info about all loaded drivers into current session.
Code:
sudo dpkg -i filename.deb
Installs a .deb file manually
Code:
sudo dpkg -i --force-overwrite filename.deb
Helpful when theres problematic .deb's which refused installing and may cause broken pipes failed configurations of packages preventing installation.
Code:
sudo dpkg --configure -a
Usually issued to finishing configuration of unconfigured packages (worth mentioning in conjunction with previous)
Code:
wget -n -q http://linktofile.com
Grabs a file with no visible output on terminal from any destination.
Code:
sudo chmod +x filename.extension
Makes a file executable though there is no need for a file extension for executable files in Linux (because Linux is great that way) usually executable files come in form of scripts e.g. filename.sh or .run packages though this is hardly a rule.
Code:
sudo ./filename.sh
sudo ./filename.run
sudo sh filename.sh
sudo sh filename.run
Runs or executes a script or .run package some scripts don't like being executed with either one or the other (usually errors out perhaps because of syntax), for this reason I found it worth mentioning this and both methods, even though script writers will let users know how to execute them.
Code:
sudo chown user:user /dir or filename
Changes owner of a directory from root:root to user:user to be used carefully, usually running this may cause failures if your modifying a /dir or filename ownership that shouldn't be modified. Dangerous command if you dont know what your doing, but helpful if you do know. This also tempts the "idiot" gene.
Code:
sudo chown user -R /dir
this changes ownership recursively not only of a directory but everything inside that directory. Dangerous command if you don't know what your doing, but helpful if you do know. This also tempts the "idiot" gene.

lshw cat /proc/cpuinfo lspci lshw -class network cat /proc/ioports cat /proc/iomem cat /proc/interrupts

Those are old commands and their respective results useful in some cases I will expand on them when I can, I dug them out of a very old post when I was 1 month into learning about the wonders and curses of Linux running jaunty on my trusted and pain in the ass Asrock ION HT 330. Basically it was meant to compare how similar ION gen 1 systems are, because they were all built by Pegatron a hardware manufacturer for the first year or two. Though to determine the similarity one had run and compare the results.

Heck the list goes on I think covering all useful commands in a thread could go on forever but I find this helpful for novices that actually are curious and want to learn about Linux. I think its a good idea even if not a new one.

Note: The use of "idiot" gene - not meant as offensive to anyone in particular but it accurately describes a widely known phenomenon. Usually associated with PEBKAC no one is immune and no known cure exists.

Note: Some of the commands I posted are dangerous indeed so when in doubt have a full system backup/image before any tinkering... This is probably the most valuable tip to prevent a massive waste of time and prevent full system reinstalls.

hope some of these commands help others same way they have helped me understand a little about Linux.

I still am a massive n00b at Linux but I try and never totally given up, persistence is key.

It only took me 4 hours to write this post... Shocked and even after double triple checking I have this feeling something is missing... ah the joys of sleep deprivation.

cheers.
(This post was last modified: 2011-06-29 01:09 by X3lectric.)
find quote
The-Boxhead Offline
Member+
Posts: 943
Joined: May 2005
Reputation: 17
Location: Norway
Post: #13
wow, great post X3lectric !

I have many of the same thoughts as you conerning writing how to's.
So i agree totally on have difficult it can be to not do more damage than good Wink

Im gonna try and take your thoughts into my org post and write
some warnings and tips. This command reference is not something i wrote
to use as a sollution, it's more a reference\toolbox that one can use when working with problems, instead of messing around on different forums each time you forget a command you know you need !

I'm gonna add your commands to the org post with your comments if it's ok ?

And yes the dist upgrade command should have a bigger warning i agree !!
Maybe i should collect all commands regarded potentially dangerous to it's own list and the safe commands to it's own list. I regard all commands that involves only listing out info as safe...

PointOfView Nvidia ION Atom 330 - TRANSCEND 2GB DDR2 DIMM 800MHz - G.SKILL 64GB SSD 2.5
Open Elec Beta4 1.95.4
XBMC Online Manual - HOW-TO post about a problem in a useful manner - Create/View Bug Report
Setup/Fix correct resolution on XBMC/Ubuntu - Usefull linux terminal commands
find quote
X3lectric Offline
Closed Account
Posts: 1,756
Joined: Feb 2006
Location: in a Dropbox
Thumbs Up  I cant get no... Satisfaction... Post: #14
The-Boxhead Wrote:snip

Im gonna try and take your thoughts into my org post and write
some warnings and tips. This command reference is not something i wrote
to use as a sollution, it's more a reference\toolbox that one can use when working with problems, instead of messing around on different forums each time you forget a command you know you need !

I'm gonna add your commands to the org post with your comments if it's ok ?

snip

Yes sure go ahead, merge away. Big Grin There is no one post anywhere on net that has all useful commands with vaguely user friendly explanations never mind ones with a warning. I get why you started this post, I feel your pain... Sad

Another pain is you'll soon find the 10k per post forums character limit, will force break the continuity/fluidity of this how-to is somewhat lost... I dont see you presaved ~5 posts on the conservative side for the half desired effect and target audience.

/me kicks the forum management to "fix" this limitation. Rolleyes This is to posting how-tos, what loosing your hard-on is to sex. cof (tumbleweed and a woosh of air)

On the dangerous commands I agree BIG warnings, heck cant make them big enough. And definitely a "segregation" of the most likely commands to cause a a potential disaster vs the safe ones.

for e.g. when you upgrade a kernel and once you are sure everything is ok with new kernel no need to keep old kernel, so I often purge the old kernel, however the dirs in usr/src and /lib/modules/ mostly remain so to remove them the usual command need to be issued.
Code:
sudo rm -rf /dir
again this is a useful command but a typo and bam you may just reboot and find your system is borked.

This is why my recent how-tos start with a strong suggestion to backup/image before tinkering, usually ignored and ppl never learn.

You wont find me doing anything unless I have a backup/image of the working system. backing up also not same as a hdd image which does not need to be a sector by sector.

This is a valuable how-to, but like all how-tos and posts these days should come with a BIG disclaimer... Eek ridiculous but true... but I digress.

Sorry for the slight rambling Off-T

cheers The-Boxhead keep it up...
(This post was last modified: 2011-06-29 16:42 by X3lectric.)
find quote
Post Reply