LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Helpful Linux commands (https://www.linuxquestions.org/questions/linux-newbie-8/helpful-linux-commands-703950/)

parent's_basement 02-11-2009 01:45 PM

Helpful Linux commands
 
Hi All,

Whenever I learn a new command, I always write it down so I won't forget it. I was going through my growing commands doc to prune it down a bit and thought my list might be helpful for people new to linux. Many of the commands most people know but some may be new to you. Please feel free to reply with some gems that you find especially helpful. Cheers and happy computing!

-pb

############################################################

alien -iv: [package name] alien converts .rpm to .deb

du -ch: /path/to/folder check file or directory size in total
amount and in human-readable terms.

dpkg-reconfigure fontconfig-config: font quality check

grub-install:*install grub on your drive*

dmesg | more: shows boot-up messages

module-assistant:*module-assistant is the command-line tool for
handling module-source packages that have been prepared for the Debian distribution. It helps users to build and install module package(s) easily for one or more custom kernels.

lsmod: lists loaded kernel modules

lspci: lists info on hardware lshw lists more detail and apt-get install hwinfo for another good tool. mkxf86config for monitor capabilities

umask: set in env.vars. (.bashrc?). Decide what your default environmental file permissions should be for thinks such as touch and text editors. Ex. U: 7 G: 5 O:0. Subtract this number from 777 and the result (027), is your umask

whatis: microscopic man page. Form: whatis mkdir

cmp: create a file, modify it and save it as a different file. use cmp to compare the differences between the two files

df -Th: report file system disk space usage
more /proc/cpuinfo: shows info on the cpu

ddcprobe: monitor info

modprobe “device” **modprobe intelligently adds or removes a module from the Linux kernel: note that for convenience, there is no difference between _ and - in module names
update-alternatives --config (item) check in /etc/alternatives for list.

alsamixer: sound input/output config gdebi

checkinstall: (run in the root directory of a package source tree). checkinstall -D turns most source into a .deb (use dpkg -i to install). The -R option turns it into a .rpm package

tar jxvf: unpacks .tar .bz package in one fell swoop

dpkg -l package* | grep -i ^ii example, lists actual package name so it can be removed (in this case by dpkg)

uname -a finds kernel version

readlink: display value of a symbolic link. The following example shows which driver module controls the eth0 device:

readlink /sys/class/net/eth1/device/driver/module

cat /proc/cpuinfo: *cpu info

apt-get moo: *just kinda fun

ifconfig [interface]*up/down: brings specified nic on or off line

top: shows real-time cpu usage by process. -U username for specific user

apropos: info on man pages- very cool*

stat [filename]: verbose info on files

dpkg --list: shows all dpkg installed packages

df -h or better yet fdisk -l:*List hard drive info/names

ctrl-alt-backspace: kills xserver

runlevel: shows current runlevel

telinit x: change runlevel

sysv-rc-conf: start/stop specifications for init scripts by runlevel. You can also go to the /etc/runlevel and replace the “S” with a “K”

update-grub: updates grub boot menu

gcc --version: gnu compiler version

tzselect:* sets timezone

pmount: ("policy mount") is a wrapper around the standard mount program which permits normal users to mount removable devices without a matching /etc/fstab entry

pstree [process]:*display a tree of processes

dhclient: requests and renews dhcp address from dhcp server


pljvaldez 02-11-2009 01:55 PM

A few more you may want to add:

lsusb -- list usb devices
lshw -- list more detailed hardware information of your system including chipsets, motherboard manufacturer, RAM details, etc (I had to install this separately from the Debian repos)

parent's_basement 02-11-2009 03:08 PM

Thanks for the additions pljvaldez!

-pb

GibsoneanNode 02-11-2009 03:10 PM

Hello parent's_basement, you have some really good commands in that list!

Commands
lsb_release -a
#OS and distribution information.
dmesg|grep WORD
#Boot messages piped, where “WORD” is the search subject.
cat /var/log/Xorg.0.log|grep EE
#list errors for the X Window System.
Link
TuxFiles: The Basics: Linux Command Line.

alan_ri 02-11-2009 04:16 PM

Ohh,you must have my favorite in that list... :D
Code:

find / -name stupid -exec /bin/rm -f '{}' \;
- Remove all stupid files in the system. :D

UPDATE:just to make things clear if they are not to somebody;if you replace word stupid with for example word john,command will delete all files named john in the system.
Here are few more;
1.
Code:

ls -l | grep Aug | wc -l
- prints the number of files in the current directory modified in August.
2.
Code:

tail -f /var/log/mail.log
- Prints the last few lines of a file and then waits, printing new lines as they are appended to the file. This is great for watching a log file.
3.
Code:

find ~ -name '*.txt' -print
- Look under your home directory for any txt files.
4.
Code:

gpg -c file
- Encrypt file.
5.
Code:

netstat -tup
- List active connections to/from the system.

Reasa 02-11-2009 04:46 PM

$cal - calendar
$ls /mnt/cdrom > file_listing - cd/dvd file listing on your hdd. Call it dvd_1 and label the corrspondent dvd with pencil dvd_1 too. To find file in this list use $grep lost_file dvd_1 , or if you are in directory with several file lists $grep lost_file * . Now finding files is easier among those hundreds of discs.

cloud9repo 02-11-2009 06:21 PM

Here's a couple more that I like to employ:

halt
reboot

As su[do], with the addition of '-n or -i', it will either reboot or halt the system. When getting attacked ferociously by hacks and what not, a quick press of Alt+F2, and run one of those in terminal, really helps prevent contamination of settings and config scripts.

The '-n' option tells the sys. there's to be no syncing, and the '-i' shuts down the interface for the network.

parent's_basement 02-11-2009 07:25 PM

cloud9repo-

Thanks! Also try these:

init 0 (halts the os)

init 6 (reboots the os)

-pb

aquaboot 02-12-2009 11:17 AM

Good to see a growing list. This is very helpful.

ab


All times are GMT -5. The time now is 12:03 AM.