 dom6791
join:2001-11-23 Bronx, NY | Little Known Tips and Tricks...
I was just wondering if some of you more knowledgeable *nix users would share some of your lesser known tips and tricks with Linux? Not including the information listed in this forums FAQs. |
|
 paul123
join:2000-11-03 Brookline, MA
| Great idea for a thread. I'll start it off with one 
In unix, the way that an application programmer would normally query the kernel for kernel information is to use the ioctl() system call if there was not a C library call already available.
In linux, if you don't want to write a program or if you didn't have a utility already available (ie. uptime, ps, etc.) to query the kernel, there is a nice facility to access kernel information using a filesystem interface. This is the /proc interface. Most common modules in the kernel support this interface method.
For example, if you do a ls -al /proc, a lot of files are listed. Nearly all of them will have a zero byte count. But there is actually useful data in there .
cat /proc/meminfo will provide information on the kernel's view of memory. cat /proc/cpuinfo will provide information on the kernel's view of the cpu.
Ever wonder about specific process information? In the /proc interface, a directory is created for each process id that the kernel is currently running.
ls -al /proc/1 will provide all the information that the kernel is tracking for process 1 which is always the init process. For example, if you are curious what environment variables was passed to the init process when it started, cat /proc/1/environ.
If you don't have the uname application and you want to find the kernel version, cat /proc/sys/kernel/osrelease.
The /proc interface can be a useful method to query the kernel. |
|
  AmateurAstro
join:2001-12-29 Glen Ridge, NJ
| reply to dom6791 If you add the "noatime" option to the fstab file for mounting options, Linux will not keep track of the access time every time a file is read. This can be of noticeable benefit on older, slower machines. I use it on my Fujitsu LifeBook 535T (133Mhz Pentium, 48MB RAM) to good effect. |
|
  fritzmp Biker Tux Premium join:2001-08-29 Warrenton, VA clubs:
edited
| reply to dom6791 Security SSH PAM and USERS: Based on RH so file location may vary
edit /etc/ssh/sshd-config
change
#Protocol 2,1
to just 2
Protocol 2
#uncomment the line
This will keep ssh to fall to a protocol 1 session where you can have man in the middle issues.
change
#PermitRootLonin yes
to
PermitRootLonin no
#uncoment the line
Root does not need to login
save and exit
add your username to the wheel group
usermod -G wheel username
edit /etc/pam.d/su
# Uncomment the following line to require a user to be in the "wheel" group. auth required /lib/security/pam_wheel.so use_uid
now you have only the users you want to su - and no external root logins and shell access you now have control some what. You do need to trust those you give access. -- NTFS Killed My Parents. Get Freed A small band of FreeBSD users are working together in the shadows, observing, honing their skills, building their numbers, and plotting their future.
[text was edited by author 2003-03-04 15:31:22] |
|
 dom6791
join:2001-11-23 Bronx, NY | reply to dom6791 Wow! These are some tips I have never heard of. Nice ones fellas! |
|
  Viggen93 Premium,VIP join:2002-04-16 Hamilton, ON
·Cogeco Cable
| reply to dom6791 Finding files in the filesystem, you could use the "find" command but that is often slow. Try using "locate filename" instead, as it is much quicker as it searches a database of the filesystem. There are limitations to locate, such as the database will only have a snapshot of the filesystem as of the last time "slocate.cron" was ran, something that is (well atleast on my system) run at midnight every day, therefore, if the file was created after the last cron job for "slocate.cron" (slocate.cron is just a script that is located in etc/cron.daily on my RH8 System) locate won't pick it up. I find it useful for finding obscure configuration files. -- Isn't air travel wonderful? Breakfast in London, dinner in New York,luggage in Brazil. |
|
  rocketspeed No Tag Premium join:2000-01-24 Los Alamos, NM
| reply to dom6791 In Mandrake 9 an application menu is created. In KDE almost all applications are there by clicking on the kde button. I don't use KDE. I prefer Fluxbox (as I know many others do). When you install Fluxbox as an afterthought, the menu is incomplete. However Blackbox may have been installed when you installed Mandrake and it has a fairly complete automatically created menu called blackbox-menu in the user directory. To get all the apps in my Fluxbox menu without manually editing it (a tedious task ) I remove the old fluxbox menu: mv ~/.fluxbox/menu ~/.fluxbox/menmu.bak
and replace it with:
ln -s ~/blackbox-menu ~/.fluxbox/menu
I can then easily edit all GUI menus by running menudrake.
Not sure how well known that is, but it sure saved me some time from menu editing. |
|
  shdesigns Powered By Infinite Improbabilty Drive Premium join:2000-12-01 Stone Mountain, GA
·Atlantic Nexus
| reply to dom6791 SSH is not just an encrypted "telnet clone". It can compress data, and act as a tunnel to or from other machines (kind of like a VPN.) It can use this tunnel to pass X-windows gui between machines (X-Forward.)
Typical example:
remote pc -->public internet IP -->router-->workstation@10.1.1.1
Workstation has VNC running on port 5900.
Set up SSH connection to router and enable forwarding:
remote pc (localhost) port 5900 --> remote IP 10.1.1.1
Then 'vncviewer localhost' (on remote PC, not in ssh login) will connect to the VNC desktop on the workstation at 10.1.1.1. You now have a route to the local LAN through the firewall to a non-routable IP. This port forward only exists between your PC and the remoteworkstation and, only exists while you are logged in.
After I had used this, I disabled all ports for things like VNC on my firewall. Only thing open is ssh and web server. When I am working at a remote site, I ssh to my router and tunnel to internal PC's as needed.
As you can see, ssh is powerful, not just a remote login.
Read the man pages on ssh and sshd.
Also putty is a great windoze ssh client. I used it on my sisters PC running off a floppy to get to one of my PC's desktop without any installed software on their PC. I did the same using knoppix on my brothers PC. -- Scott Henion Embedded Systems Consultant, shenion on #ATUhttp://shdesigns.org |
|
 cpuffer
join:2002-01-17 Maynard, MA
| reply to dom6791 Cygwin
Cygwin is your friend if you are forced to use NT/2000... It gives you a bash shell, ssh, X windows and your faverate commands like grep and ls.
I like the fact that I can do bash and pearl scripts and run X with ssh logging into my home system.
So get Cygwin it installs easy and works. It also has an updater like debian so you can keep all your code up to date.
Charles Puffer |
|
  DewiM Premium join:2001-09-28 united kingd | reply to dom6791 Re: Little Known Tips and Tricks...
I wrote a quickie cheat sheet for RPM, so I'll enter that as my tip 
»RPM quickie cheat sheet |
|
  limeygit Everybody Wang-Chung Tonight
join:2001-02-17 Nearest Bar
| reply to dom6791 I am very much a newb, but here is something I found nice and easy. How to use your windows fonts in Open Office on RH8. This assumes you still have windows and there is a cd-burner on it. If you don't have windows you can do it this way - »corefonts.sourceforge.net/.
(1) Anyway, first burn a CD with all the fonts you want, or just do what I did and burn a copy of the windows Fonts directory. (2) Pop the CD into the linux machine. (3) Make a directory in red hat, it is probably best to make a hidden one in home. mkrdir ~/.fonts (4) Open a terminal window and move to your cd drive probably just need to cd /mnt/cdrom/Fonts - assuming you burned the whole folder from windows. (5) Copy the files from the cd to your new Red Hat fonts folder. cp *.ttf ~/.fonts will work if you made the hidden folder in your home. If not alter as needed. (6) Apparently in RH8, many applications will see the new fonts without you needing to do anymore. What I care about though is Open Office, and with that you need to import the fonts. To do this open a terminal and type oopadmin. This will load a simple screen where you can select fonts, and then add, and then point it to your fonts folder, select all, and add. Viola, you can use Verdana or whatever in your OO documents.
If this is a 'well duh', I apologize, I know I found it a nice and easy way to do it, easier for a newb than the corefonts install method anyway. Not sure if it works on other distros. -- www.indiemonkey.com Taking you to Funky Town since 1999! |
|
  computx Is it Friday yet? Premium join:2000-09-02 Kirksville, MO
| reply to dom6791 when I add a task to the crontab its hard for me to remember what the order of the time fields are. So I always append these comments to the top of the crontab as a reminder.
code:
# 1 the first field denotes the minute, # 2 the second the hour, # 3 the third the day of month, # 4 the fourth the month (by number or short name) # 5 the fifth the day of the week (by number or short name)
I add this comment to my fstab as a reminder also
code:
# partition mountpoint type opts dump/pass
-- To err is human...to really foul up requires the root password. |
|
  Skipdawg The Original Premium,ExMod 2001-03 join:2001-04-19 The Void
·surpasshosting
| reply to dom6791 Here is a sites page I've been cheching out today.
An Introduction to the Linux Command Line Interface, The Core 15 Commands »www.wtlug.org/story.php/view/54/ -- Proud US Navy Veteran. |
|
  phriday613 Your Avatar Is Nice... For Me To Poop On Premium join:2002-02-06 Eastchester, NY clubs:
·RoadRunner Cable
·Optimum Online
·Coredial
| reply to dom6791 neato tip i just found!
/sbin/iptables -xnvL will output a list of all your iptables rules AND a packet counter and byte counter as well!
neat if you want to create a script that could output bytes in/out, based on your iptables rule chains counting bytes in and out! -- Help find a cure for Cancer - Join Team Discovery! |
|
  nobody65534
@rr.com
| reply to dom6791 Need to give root access to someone quickly but don't want to share your password or fuss with sudo et al?
add another user, say "newroot" change the UID & GID to 0 for both and change its password
Like root, users can't log in remotely. IE, the user needs to log in first and then su newroot |
|
  SuperJudge Magus Premium join:2002-11-14 Albany, GA clubs: | reply to dom6791 Sweet. |
|
  elluzion
join:2002-10-15 Nashville, TN
| reply to dom6791 This may be old news to many, but it was certainly a shock to me...
You can get access to a Linux computer without logging in by typing "linux single" at the LILO "boot:" prompt. I think you can type "linux emergency" as well and get the same effect.
If you use graphical LILO, you'll have to hit ctrl-x to get to the prompt.
It boots the computer to runlevel 1, so the network isn't initiated or anything, but it's enough to access files and all that. This is so you can fix any screw ups you may have made which are prohibiting you from logging in.
There's a way to do it with GRUB also, but i don't know how.
I guess this is why important computers, even Linux computers, should be physically, not just virtually, locked up. |
|
  Ozz_man
join:2002-03-31 Marion, IL
·Mediacom
| reply to dom6791 This is one of the best threads I have ever seen here and I hope more and more can keep adding to it. I have learned a few things already that unlocked secrets I never knew possible, and has enhanced my Linux experience tremendously.
Good job guys |
|
  davidsmind The Eye's Mind Premium join:2001-07-04 Canada
| reply to elluzion said by elluzion :
There's a way to do it with GRUB also, but i don't know how.
Append init=/bin/bash to the end of your grub item  -- Be Windows Free By 2003!!! |
|
 AITechSE
join:2002-12-12 USA
edited
| reply to dom6791 Lose a file on your file system? Or want to find every file with foo in it? Try this as root in /:
find .. | grep foo
It takes a bit but it will find everything.
BTW, it will work as a regular user, it just won't be able to search directories you don't have access to (i.e. /root). [text was edited by author 2003-03-05 20:52:36] |
|