Linux Tricks and Commands Just hit Back Icon to return to webpage +++++++++++++++++++++++++++++++++++++++ Bill Rosoman http://leftfieldnz.topcities.com leftfieldnz@yahoo.co.uk August 2004 # Just some Tips I have picked up in my use of Linux (Mandrake 10) axyftp does proper Binary and ASCII transfers checkinstall Checks RPMs? kappfinder KDE App finder iwconfig WIFI chkconfig --list www.slingshot.co.nz 202.180.64.20 popcheck -s pop.mail.yahoo.com -u leftfieldnz -p password popcheck -s pop3.ihug.co.nz -u avantgarden4 -p password popcheck -s pop.mail.yahoo.com -u nugrownz -p password prozilla file download proz http://leftfieldnz.topcities.com/bill/docs/tricks.txt find /usr -cmin -10 excuteable files installed in last ten minutes To Change to the ext3 File System As Root tune2fs -J FS-name Use uname -r to find your file system name. The Append the fstab config file and add /dev/hda6 / ext3 noatime 1 1 in the first line hda6 is the partition were Linux is This will give faster boot time. fdisk -l gives partition info cat /proc/version gives info on FS resolv.conf Add DNS of ISP cat /proc/version cat /proc/cpuinfo cat /proc/interrupts cat /proc/pci cat /proc/fb cat /proc/meminfo # Firewall had too enable firewall in mcc > Secuirty > Firewall > Unclick everything (none) > select level then installed shorewall iptables -L shorewall stop shorewall status but it then blocks my LAN So need to have on ppp or adsl not eth0 # For Pencam Pictures (Aiptek) rmmod stv680 gtkam to download # Pencam Webcam (Aiptek) Leave in Module stv680 insmod stv680 Just as easy to remove Camera and reinstall # Win Modem (PCTel) modprobe slamr /usr/sbin/slmodemd --country=nz /dev/slamr0 slmodem insmod -f slamr0 modprobe slamr /dev/ttySL0 ./scanmodem slmodemd in separate shell kppp wvdialconf wvdial.conf wvdial minicom echo "atdt0800" > /dev/ttySL0 atz reset ath hangup setserial yahoopops proz # Basic Linux I am using Linux, Mandrake 10 and KDE 3.2 When I installed Mandrake I installed both KDE and Gnome Desktops and most of the items I could think of at the time. I have downloaded more stuff like Star Office and have installed more from the Mandrake CDs. I have still to work out what I actually have on the computer and how to use it! I can now do 99% of what I could do in Windows and could do the rest once I get my Modem to actually work properly (I can connect but do not know what to do next) I pobably can do the other things I want in Wine (A Windows Emulator), but have not really figured it out yet! If the going gets tough or I kill GUI, I use a Knoppix CD to see what is going on in a computer and to make changes. Remember Linux has a pretty high security and you will have to change ownership's and permissions of folders and files often! # Linux Acts much Like Windows in the X Mode (Windows and GUI). It also uses some of the same Commands; CTRL+C Copy CTRL+V Paste CTRL+X Cut CTRL+P Print CTRL+S Save CTRL+O Open CTRL+B Bold CTRL+U Underline CTRL+N New File CTRL+E Center CTRL+A Select All CTRL+R Replace F5 Reload/refresh F2 Rename F3 or CTRL+F Find F7 Spell Check CTRL+R Replace HOME Beginning of line CTRL+HOME Beginning of file END End of Line CTRL+END End of File DEL Delete ALT+F4 Exit Program # Linux have a few commands of their own as well CTRL+W Close File CTRL+Q Quit ALT+F4 also works This is for common Wordprocessor and spreadsheet etc programs like Open Office and Star Office. For the most common programs and utilities that I use I have created a Quicklaunch folder on the Desktop with a shortcut in the Tool Bar. I then create a Shortcut by Right Clicking in the folder and create new > file > link to application. However some have to be done in Root or SU mode. Linux like Unix is Case Sensitive (not like Windows) # A lot of stuff (Configuration, Permissions, Testing, etc) is done in a Shell or Terminal (called BASH) Start > System > Terminals or from the Tool Bar (A Black Box Icon) Start Bottom left of Toolbar at bottom of screen, Lists Applications and Logout Shift+Ins In shell Inserts from Clipboard Tab In shell completes text say cd Doc TAB will give Documents Up Arrow In shell Last Commands Down Arrow In shell Previous Commands You can highlight Shell ouput then go Edit Copy and then paste into a document etc. [root@mordor leftfieldnz]# cal June 2004 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Like this above CRTL+ESC List Processes and can kill them from here CTRL+ALT+Backspace Exit X Windows (GUI) ALT+F2 Run Command ALT+F4 Exit Program CTRL+TAB Change Windows ALT+TAB Rotate through open Programs CTRL+ALT+ESC Kill A Process Click Skull and Cross Bones on the Process you wish to kill SU (Super User Mode) Root Admin, to change configuration files, ownership's, permissions, etc --help On most files will give help like, rpm --help gives options -v On most files will give Version of file like, rpm -v man program Will give a manual for the program man rpm Hi CTRL+Z to exit cal Calendar adduser name To add a user to Linux, prompted for a password locate filename ./j2re-1_4_2_04-linux-i586-rpm.bin Execute a self-extracting file top Displays Process and CPU Memory use, Press M Memory P CPU info I Info Q Quit reboot Reboots poweroff Shutdown kappfinder Find New KDE Menu items kfloppy format a floppy mkbootdisk Make Boot Floppy mkrescue Make Rescue Floppy acpi -V Check Power Management (Notepads mainly) hdparm -t -T Hard disk speed hdparm Hard disk settings chkconfig --list List process running echo "atz" > /dev/ttySLO reset modem echo "ath" > /dev/ttySLO hangup modem echo "atdt0800000000" > /dev/ttySLO dial number modprobe modulename Probe a Module rmmod modulename remove module cat /dev/urandom > /dev/dsp should hear white sound thru speakers cat /proc/pci List PCI Devices dig passwd root or user to change password exit Exit from current user startx Start Windows GUI from shell kcontrol KDE Control Centre Alter KDE System Stuff, Menus, Sound etc mcc Mandrake Control Centre Alter Mandrake stuff, Test/Configure Hardware, Install Packages etc modprobe sound Check Sound chgrp = modify group permissions chmod 777 *.* RWX all files, modify permissions [chmod 644 filename.html] chown leftfieldnz : *.* change owner all files shift+insert keys to insert clipboard into shell du Disk used df Disk Free fdisk -l List Disk Drives artscontrol Sound Control aumix -q Sound Control Make sure not set at zero kmix KDE Sound # To Install Software (Mandrake, Redhat, SUSE) rpm -i package.name Install rpm -i --force --nodeps Force Install rpm -e Erase rpm -q Query rpm --rebuilddb Rebuild RPM Database updatedb Update File Data Base # Some Configuration Files Use your Favourite Editor (Kate, Kedit, Emacs, Kwrite) and in SU (Super User Mode) type Kate /etc/host.conf in a Shell and Press Enter, etc /etc/lilo.conf /etc/samba/smb.conf /etc/X11/XF86Config-4 X Server /etc/modules.conf /etc/devfsd.conf /etc/host.conf /etc/fstab /etc/resolv.conf http://localhost:901/ SWAT for samba kate /etc/xinetd.conf setserial ctrl+Z Break lspci -vvv List PCI Devices tail -s 3 -f /var/log/messages List Kernel Messages dmesg List Messages kill Kill a Process killall cd.. Up One level (Parent) uname -a List Kernel version # If X (GUI or Windows) will not run try; emacs /etc/lilo.conf & Edit Lilo Boot /sbin/lilo -v Re-Run Lilo so changes take effect emacs /etc/rc.d/rc.local/ emacs /etc/samba/smb.conf Config SAMBA emacs /etc/fstab Drive/Device setup (Hard Drive, CD, Floppy, memory stick The main command for Emacs is F10 for the menu then File Save etc. lsmod lsmod | grep -i usb lsmod | grep -i scsi lsmod | grep -i sound lsmod | grep -i mouse Lists modules dmesg System Info dmesg | grep agp AGP Graphics Card dmesg | grep drm dmesg | grep PCI PCI Info Mount/Unmount Drive/Device mount /dev/sda /mnt/stick Mount Memory Stick cd /mnt/stick Change to Stick ls List Files/Folders umount /dev/sda /mnt/stick Mount Memory Stick # To compile a file CD to the folder it is in and; ./configure make make install chmod 777 *.* # Network LAN route -n ping 192.168.0.1 or ping www.cnn.com CTRL+Z to stop nmblookup -B BIGSERVER __SAMBA__ smbclient -L BIGSERVER nmblookup -d 2 '*' dhclient eth0 cat /etc/sysconfig/network View Network Info /etc/resolv.conf cat /dev/dsp ifconfig eth0 smbstatus SAMBA Status (Network) search mshome.net nameserver 192.168.0.1 host -l mordor hostname kedit /etc/hosts testparm /etc/samba/smb.conf nslookup nmap -sS www.paradise.net.nz smbpasswd leftfieldnz Add SAMBA Password # When no Network In Shell ifdown eth0 Shutdown NIC (Network Card) samba stop Stop SAMBA (Windows Network) BTW I now use smb4k to read accross the Network I also like Nautilus for browsing Network # To restart Network ifup eth0 samba start # Windows Command Start > Run > Command or cmd then; CD /windows Change Directory DIR List Directory net view \\BIGSERVER netsat -no # Other Linux Commands 1. Navigation - how to get around * cd - changing directories * ls - listing files * pwd - knowing where you are 2. File Management - who needs a graphical file manager? * cp - copying files * ln - creating symbolic links * mv - moving and renaming files * rm - removing files 3. Editing - using text editors for those nasty configuration files * emacs - another widely used text editor * pico - for wussies like myself * vim - an improved version of the standard Unix text editor 4. Monitoring Your System - to satisfy your insatiable curiosity * tail - follow a file as it grows * top - a program to see how your memory and CPU are holding up * w - look at who's logged on * dmesg - system info mkdir make folder rmdir remove folder gunzip {file.gz} uncompresses a file gzip {file} compresses a file tar -xvf {file.tar} undoes a tape archive file, breaking it into its stored subfiles tar -xzvf {file.tgz or file.tar.gz} undoes a compressed tape archive file, breaking it into its stored subfiles w shows who is on the system and what they are currently running who shows who is on the system gabber is front end for jabber wine "/path/program.exe" genealogy lifelines llines knoppix noscsi or knoppix 2 f-prot -dumb -list -rename /home/leftfieldnz/Document Virus check f-prot -dumb -list -rename / For whole Hard Drive Results of virus scanning: Files: 169189 MBRs: 0 Boot sectors: 0 Objects scanned: 247476 Infected: 1 Suspicious: 1 Disinfected: 0 Deleted: 0 Renamed: 1 kwikdisk is called kdf ifdown eth0 Stop Network ifup eth0 Start Network ifconfig Network Info cp -a /mnt/cdrom . copy all files of cd to current folder ktouch Touch typing program dd if=/dev/cdrom of=knoppixstd.iso Creates and iso of CD airsnort for wifi On Knoppix CD testdisk using Knoppix # ACPI Power Management on my Notepad (Dell Inspirion 2650) /proc/acpi/sleep /proc/acpi/info /proc/acpi/battery/BAT1/info /proc/acpi/battery/BAT1/state update-menus -v wvdial wvdialconf wvdial.conf kppp Dialer /dev/dsp sound depmod -a /dev/input/mice kcontrol > sound > hardware > set to 32000 minicom nolapic noapic in lilo testparm # Programs I Like axyftp cinepaint deadftp Disk Free dynamic_dev_v4l_video0_dynamic epiphany Evolution Galeon gftp Gimp GQViewer Grip CD Rip GTKam GTM Home Kasablanca Kcalc Kmix KolourPaint konqbrowser konsole Kopete kscd lynx mcc Mozilla M Player Poweroff Quanta Re-Boot SMB4K Star Office Stick Totem Xine xmms XPP aumix Blue Fish fdisk hdparm ifconfig eth0 kappfinder kfloppy kppp ktouch kwikdisk lspci mkbootdisk mkrescue msnm Nautilus ncftp OpenOffice setserial smbstatus tail -s 3 -f %252fvar%252flog%252fmessages update-menus USBView # Utilities kfloppy lspci Prozilla Popcheck # Misc The uid for the user in smbpasswd is different from that in /etc/passwd If you get a "network name not found" or similar error then netbios name resolution is not working. This is usually caused by a problem in nmbd. To overcome it you could do one of the following (you only need to choose one of them): - fixup the nmbd installation - add the IP address of BIGSERVER to the "wins server" box in the advanced tcp/ip setup on the PC. - enable windows name resolution via DNS in the advanced section of the tcp/ip setup - add BIGSERVER to your lmhosts file on the PC. If you get a "invalid network name" or "bad password error" then the same fixes apply as they did for the "smbclient -L" test above. In particular, make sure your "hosts allow" line is correct (see the man pages) Also, do not overlook that fact that when the workstation requests the connection to the samba server it will attempt to connect using the name with which you logged onto your Windows machine. You need to make sure that an account exists on your Samba server with that exact same name and password. If you get "specified computer is not receiving requests" or similar it probably means that the host is not contactable via tcp services. Check to see if the host is running tcp wrappers, and if so add an entry in the hosts.allow file for your client (or subnet, etc.) Run the command "net use x: \\BIGSERVER\TMP". You should be prompted for a password then you should get a "command completed successfully" message. If not then your PC software is incorrectly installed or your smb.conf is incorrect. make sure your "hosts allow" and other config lines in smb.conf are correct. It's also possible that the server can't work out what user name to connect you as. To see if this is the problem add the line "user = USERNAME" to the [tmp] section of smb.conf where "USERNAME" is the username corresponding to the password you typed. If you find this fixes things you may need the username mapping option. TEST 10: Run the command "nmblookup -M TESTGROUP" where TESTGROUP is the name of the workgroup that your Samba server and Windows PCs belong to. You should get back the IP address of the master browser for that workgroup. If you don't then the election process has failed. Wait a minute to see if it is just being slow then try again. If it still fails after that then look at the browsing options you have set in smb.conf. Make sure you have "preferred master = yes" to ensure that an election is held at startup. TEST 11: From file manager try to browse the server. Your samba server should appear in the browse list of your local workgroup (or the one you specified in smb.conf). You should be able to double click on the name of the server and get a list of shares. If you get a "invalid password" error when you do then you are probably running WinNT and it is refusing to browse a server that has no encrypted password capability and is in user level security mode. In this case either set "security = server" AND "password server = Windows_NT_Machine" in your smb.conf file, or enable encrypted passwords AFTER compiling in support for encrypted passwords (refer to the Makefile). Thanks for all the info gathered from other resouces!