This is a discussion on Linux Tips & Tricks within the Operating Systems forums, part of the Computer Hardware/Software and Networking category; I want to issue a "clearscreen" in or after a logout command so that the next login is ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| I want to issue a "clearscreen" in or after a logout command so that the next login is on a blank screen. How can I accomplish this? Solution I used to use an alias: alias bye = "clear && exit" Another viable solution, if you use the bash shell, I believe you can add the word "clear" on one line of your ~/bash_logout, and the screen will be cleared for you. |
| Sponsored Links |
| |||
| If I'm idle for about 10 minutes, my screen turns black, how do I turn that off or start a screen saver? Solution To disable blanking for the text consoles: setterm -blank 0 To disable X server screen blanking: xset s off To get a (great!) screensaver for X, install the xscreensaver package and add the following to your ~/.xsession (for XDM) or equivalent for startx (.xinitrc? not sure what Debian uses): xset s off xscreensaver & These lines should precede the one that execs your window manager. My .xsession is: =========================== #!/bin/sh xset s off xscreensaver & exec fvwm2 =========================== |
| |||
| Keep Logs Longer with Less Space. Normally logs rotate monthly, over writing all the old data. Here's a sample "/etc/logrotate.conf" that will keep 12 months of backup compressing the logfiles $ cat /etc/logrotate.conf # see "man logrotate" for details # rotate log files weekly #chirico changes to monthly monthly # keep 4 weeks worth of backlogs # keep 12 months of backup rotate 12 # create new (empty) log files after rotating old ones create # uncomment this if you want your log files compressed compress # RPM packages drop log rotation information into this directory include /etc/logrotate.d # no packages own wtmp -- we'll rotate them here /var/log/wtmp { monthly create 0664 root utmp rotate 1 } # system-specific logs may be also be configured here. |
| |||
| SSH - How to Generate the Key Pair. On the local server $ ssh-keygen -t dsa -b 2048 This will create the two files: .ssh/id_dsa (Private key) .ssh/id_dsa.pub (Public key you can share) Next insert ".ssh/id_dsa.pub" on the remote server in the file ".ssh/authorized_keys" and ".ssh/authorized_keys2" and change the permission of each file to (chmod 600). Plus, make sure the directory ".ssh" exists on the remote computer with 700 rights.Ok, assuming 192.168.1.155 is the remote server and "donkey" is the account on that remote server. $ ssh donkey@192.168.1.155 "mkdir -p .ssh" $ ssh donkey@192.168.1.155 "chmod 700 .ssh" $ scp ./.ssh/id_dsa.pub donkey@192.168.1.155:.ssh/newkey.pub Now connect to that remote server "192.168.1.155" and add .ssh/newkey.pub to both "authorized_keys" and "authorized_keys2". When done, the permission on (This is on the remote server) $chmod 600 .ssh/authorized_key* Next, go back to the local server and issue the following: $ ssh-agent $SHELL $ ssh-add The "ssh-add" will allow you to enter the passphrase and it will save it for the current login session. You don't have to enter a password when running "ssh-keygen" above. But,remember anyone with root access can "su - <username>" and then connect to your computers. It's harder, however, not impossible, for root to do this if you have a password. |
| |||
| Convert Epoch Seconds to the Current Time. Note, some programs like Nagios list epoch seconds. Here's a way to do the conversion. $ date -d "1970-01-01 1184521826 sec GMT" Sun Jul 15 13:50:26 EDT 2007 |
| |||
| emacs - commands in your ~/.emacs file to disable splash screen startup message. ;;disable splash screen and startup message (setq inhibit-startup-message t) (setq initial-scratch-message nil) |
| |||
| biosdecode - Querying the Bios from the command prompt. This command can be executed as followed from root: $ biosdecode SYSID present. Revision: 0 Structure Table Address: 0x000F0411 Number Of Structures: 1 SMBIOS 2.3 present. Structure Table Length: 2570 bytes |
| |||
| cat - header, stdin, and footer. (Working with /dev/fd/0 or -) If you have data from a command that you want preceded by the contents of a header file and followed by data in a footer file, then, the following command may help. $ w|cat header /dev/fd/0 footer Above the output of the "w" command follows the contents of the header file. Note "/dev/fd/0" refers to stdin. Yes, you could use "-" in its place in this situation. However, if "-" is used as the first argument, it will be interpreted as as a command line option, whereas "/dev/fd/0" would not. |
| |||
| Bash Brace Expansion $ echo f{ee,ie,oe,um} fee fie foe fum This works with almost any command $ mkdir -p /work/junk/{one,two,three,four} |
| |||
| FTP auto-login. "ftp" to a site and have the password stored. For instance, here's a sample ".net" file in a user's home directory for uploading to sourceforge. Note, sourceforge will take any password, so m@temp.com is used here for login "anonymous". $ cat ~/.netrc machine upload.sourceforge.net login anonymous password m@temp.com default login anonymous password user@site It might be a good idea to change the rights on this file $ chmod 0400 ~/.netrc #!/bin/bash # # Sample ftp automated script to download # file to ${dwnld} # dwnld="/work/faq/unix-faq" cd ${dwnld} ftp << FTPSTRING prompt off open rtfm.mit.edu cd /pub/usenet-by-group/news.answers/unix-faq/faq mget contents mget diff mget part* bye FTPSTRING Sourceforge uses an anonymous login with an email address as a password. Below is the automated script I use for uploading binary files. #!/bin/bash # ftp sourceforge auto upload ftpup.sh # Usage: ./ftpup.sh <filename> # # machine upload.sourceforge.net user anonymous m@aol.com ftp -n -u << FTPSTRING open upload.sourceforge.net user anonymous m@aol.com binary cd incoming put ${1} bye FTPSTRING (Also see TIP 114 for ncftpget, which is a very powerful restarting ftp program) |
| |||
| Less is More -- piping to less to scroll backword and forward For large "ls" listings try the followin, then, use the arrow key to move up and down the list. $ ls /some_large_dir/ | less or $ cat some_large_file | less or $ less some_large_file |
| |||
| Moving around Directories. Change to the home directory: $ cd ~ or $ cd To go back to the last directory $ cd - Instead of "cd" to a directory try "pushd" and look at the heading...you can see a list of directories. $ pushd /etc $ pushd /usr/local Then, to get back "popd" or "popd 1" To list all the directories pushed on the stack use the "dirs -v" command. $ dirs -v 0 /usr/local 1 /etc 2 /work/souptonuts/documentation/theBook Now, if you "pushd +1" you will be moved to "/etc", since is number "1" on the stack, and this directory will become "0". $ pwd /usr/local $ pushd +1 $ pwd /etc $ dirs -v 0 /etc 1 /work/souptonuts/documentation/theBook 2 /usr/local TIP 39: Need an Underscore after a Variable? Enclose the variable in "{}". $echo ${UID}_ Compare to $echo $UID_ Also try the following: $ m="my stuff here" $ echo -e ${m// /'\n'} my stuff here |
| |||
| Editing a Bash Command Try typing a long command say, then, type "fc" for an easy way to edit the command. $ find /etc -iname '*.cnf' -exec grep -H 'log' {} \; $ fc "fc" will bring the last command typed into an editor, "emacs" if that's the default editor. Type "fc -l" to list last few commands. To seach for a command, try typing "CTL-r" at the shell prompt for searching. "CTL-t" to transpose, say "sl" was typed by you want "ls". Hints when using "fc: in emacs: ESC-b move one word backward ESC-f move one word forward ESC-DEL kill one word backward CTL-k kill point to end CTL-y un-yank killed region at point |
| |||
| Getting a List of User Accounts on the System $ cut -d: -f1 /etc/passwd | sort Note (Thanks to Philip Vanmontfort) you can also do the following: $ getent passwd|cut -d: -f1|sort |
| |||
| Bash Brace Expansion $ echo f{ee,ie,oe,um} fee fie foe fum This works with almost any command $ mkdir -p /work/junk/{one,two,three,four} |
| |||
| Need to Find the Factors of a Number? $ factor 2345678992 2345678992: 2 2 2 2 6581 22277 It's a quick way to find out if a number is prime $ factor 7867 7867: 7867 |
| |||
| Keeping Files in Sync Between Servers. The remote computer is "192.168.1.171" and has the account "donkey". You want to "keep in sync" the files under "/home/cu2000/Logs" on the remote computer with files on "/home/chirico/dev/MEDIA_Server" on the local computer. $ rsync -Lae ssh donkey@192.168.1.171:/home/cu2000/Logs /home/chirico/dev/MEDIA_Server "rsync" is a convient command for keeping files in sync, and as shown here will work through ssh. The -L option tells rsync to treat symbolic links like ordinary files. |
| |||
| Looking up the Spelling of a Word. $ look <partial spelling> so the following will list all words that start with stuff $ look stuff stuff stuffage stuffata stuffed stuffender stuffer stuffers stuffgownsman stuffier stuffiest stuffily stuffiness stuffinesses stuffiness's stuffing stuffings stuffing's stuffless stuffs stuffy It helps to have a large "linuxwords" dictionary. You can download a much bigger dictionary from the following: SourceForge.net: Downloading ... Note: vim users can setup the .vimrc file with the following. Now when you type CTL-X CTL-T in insert mode, you'll get a thesaurus lookup. set dictionary+=/usr/share/dict/words set thesaurus+=/usr/share/dict/words Or, you can call aspell with the F6 command after putting the folling entry in your .vimrc file :nmap <F6> :w<CR>:!aspell -e -c %<CR>:e<CR> Now, hit F6 when you're in vim, and you'll get a spell checker. There is also an X Windows dictionary that runs with the following command. $ gnome-dictionary |
| |||
| Find out if a Command is Aliased. $ type -all <command> Example: $ type -all ls ls is aliased to `ls --color=tty' ls is /bin/ls |
| |||
| Create a Terminal Calculator Put the following in your .bashrc file function calc { echo "${1}"|bc -l; } Or, run it at the shell prompt. Now "calc" from the shell will work as follows: $ calc 3+45 48 All functions with a "(" or ")" must be enclosed in quotes. For instance, to get the sin of .4 $ calc "s(.4)" .38941834230865049166 |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C# .Net Tips & Tricks | oxygen | C# Programming | 85 | 01-08-2009 01:25 AM |
| SAP Tips & Tricks | leoraja8 | Operating Systems | 0 | 03-29-2008 01:11 AM |
| Digital Photo Management In Linux Tips and Tricks | Sabari | Server Management | 5 | 12-01-2007 03:15 AM |
| .NET tricks & Tips | Karpagarajan | VB.NET Programming | 1 | 04-23-2007 09:17 AM |
| SEO Tips & Tricks | spid4r | Search Engine Optimization | 0 | 03-09-2007 12:03 AM |