Search

Thursday 18 March 2010

Linux command lines I always forget!

Various list commands:
Normal - ls
Display dir contents (long format) - ls -l
Display dir contents (reverse) - ls -r
Display dir contents (hidden files) - ls -a

Directory creation:
mkdir folder1

Delete directory:
rmdir folder1

Delete directory and its contents:
rmdir -r folder1

Copy directories:
cp -r folder1 folder2

Move directory:
mv folder1 folder2

Delete file or directory:
rm /home/cheese.doc

View a file:
view xx (q to quit)

Show disk space:
df (see other posts on df)

Show all running processes:
ps aux

Copy a file to  make a backup:
cp /etc/X11/xorg.conf /etc/X11/xorgbak.conf

Restore the backup:
cp /etc/X11/xorgbak.conf /etc/X11/xorg.conf

Keep an eye on any hardware you plug into your Linux box
dmesg | tail -f

Modify the EXIM4 MTA on Ubuntu to mail to the outside world:
dpkg-reconfigure exim4-config

Linux APT commands

After initial install run:
sudo apt-get update

To update installed applications:
sudo apt-get upgrade

To install the 'cheese' package:
sudo apt-get install cheese

To remove the 'cheese' package:
sudo apt-get remove cheese

To clean the APT database:
sudo apt-get clean   or sudo apt-get autoclean

To have a good clear up:
sudo apt-get autoremove

Monday 1 March 2010

Copy Windows desktop shortcuts from one profile to another - script


@echo off
REM Script to set new user desktop icons
COLOR 0a
CLS
@ECHO Hello %username%
@ECHO This Script will set up your desktop icons
SET /p name= Please enter the username for the profile you want ot copy icons from…?
if “%allusersprofile%”==”C:\ProgramData” goto WinVista7
if %os%==Windows_NT goto WinXP
:Winvista7
CLS
@ECHO Windows 7 or Vista Operating System Detected
REM If Windows Vista or WIndows 7
copy C:\Users\%name%\Desktop C:\Users\%username%\Desktop
@echo I’m Done!
EXIT
:winxp
CLS
@Echo Windows XP Operating System Detected
REM If Windows XP
copy “C:\Documents and Settings\%name%\Desktop
” “C:\Documents and Settings\%username%”
@echo I’m Done!
EXIT
@echo off
REM Script to set new user desktop icons
COLOR 0aCLS
@ECHO Hello %username%
@ECHO This Script will set up your desktop icons SET /p name= Please enter the username for the profile you want ot copy icons from…?
if “%allusersprofile%”==”C:\ProgramData” goto WinVista7if %os%==Windows_NT goto WinXP
:Winvista7
CLS@ECHO Windows 7 or Vista Operating System Detected
REM If Windows Vista or WIndows 7
copy C:\Users\%name%\Desktop C:\Users\%username%\Desktop
@echo I’m Done!
EXIT
:winxp
CLS@Echo Windows XP Operating System Detected
REM If Windows XP
copy “C:\Documents and Settings\%name%\Desktop” “C:\Documents and Settings\%username%”
@echo I’m Done!
EXIT

Windows DNS Servers records become stale and get deleted


To prevent manually added DNS names assign to static IP hosts from being deleted (automatic scavenging) use the following guidelines:
Best practice is usually to leave the no-refresh and refresh intervals to 7 days each. 1 day will result in to much scavenging activity and records may be deleted before they are refreshed. Do your servers have static ip addresses, they should not be configured by DHCP. Servers configured with static ip addresses will refresh their dns records often enough (every 24 hours i believe) to negate the possibility of being scavenged assuming the scavenging period is set appropriately, i.e. not less than the DHCP lease time. This is so that machines with dynamic addresses are not at risk of having their record deleted from DNS.

Postfix - prevent certain domains from sending to your server


Add the following line in /etc/postfix/main.cf

  • smtpd_sender_restrictions = hash:/etc/postfix/access
then modify the access text file in /etc/postfix/ to include the list of rejected senders (similar to below)
  • aol.com     REJECT
Then open a terminal window and ‘re-hash’ the access file with the following command
  • postmap hash:/etc/postfix/access
Now restart Postfix