Source Insight Tips and Tricks and Tweaks
->
Option -> Document Options -> Document Type -> Include when adding to projects
Options -> Document Options -> Document Type -> Add Type
4. Add new files to project automatically
Project -> Synchronize Files -> Add new files automatically
5. Show full path of source code file
Preference -> Display -> Trim Long Path Names With ellipses
6. Project dependency
Option -> Preference -> Symbol Lookups -> Add Project to Path
7. Create common projects
Option -> Preference -> Symbol Lookups -> Create Common Projects
8. Colors
Background Color: Option -> Preference -> Windows background -> Color
Foreground Color: Option -> Preference -> Default Text -> Color
9. Fonts
Options -> Document Options -> Document Type -> Screen/Print Font
NOTE: Options -> Style Properties has more control on each element's font and color. You can save all your settings as disk file and share it with others in this dialog box.
10. Fixed width view
View -> Draft View, actually, ignore all style settings
11. Shortcut Keys
Use can set using: Options -> Key Assignment
The common default settings are:
Ctr l+ = : Jump to definition
Alt + / : Look up reference
F3 : search backward
F4 : search forward
F5: go to Line
F7 : Look up symbols
F8 : Look up local symbols
F9 : Ident left
F10 : Ident right
F12 : incremental search
Alt+, : Jump backword
Alt+. : Jump forward
Shift+F3 : search the word under cusor backward
Shift+F4 : search the word under cusor forward
Shift+F8 : hilight word
Shift+Ctrl+F: search in project
12. Custom Command
Options -> Custom command
There are many substitution chars you can use when invoking the command, for example:
%f - full path of current file
%l - line number of current file
%d - full dir path of current file
Full list can be found in SI's help doc: Command Reference -> Custom Commands -> Command Line Substitutions
13. Macros
Source Insight provides a C-like macro language, which is useful for scripting commands, inserting specially formatted text, and automating editing operations. Macros are saved in a text file with a .EM extension. Once a macro file is part of the project, the macro functions in the file become available as user-level commands in the Key Assignments or Menu Assignments dialog boxes.
For language reference, see "Macro Language Guide" section in SI help doc.
SI's web site also contains some sample macro files: http://www.sourceinsight.com/public/macros
14. Special Features
Conditional Parsing:
- This is similar to conditional compiling for C/C++, chose what statements to parse
- You can change the settings using: Project -> Project Settings -> Conditions
How to create a symlink in the Linux command console?
->
ln -s <destination> <linkname>
If the desired link filename is the same as the destination's filename, and the current working directory is the desired location for the link, then you only need:
ln -s <destination>
A symbolic link (also symlink or soft link) is a special type of file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution. Symbolic links were already present by 1978 in mini-computer operating systems from DEC and Data General's RDOS.
Today they are supported by the POSIX operating-system standard, most Unix-like operating systems such as FreeBSD, GNU/Linux, and Mac OS X, and also Windows operating systems such as Windows Vista, Windows 7 and to some degree in Windows 2000 and Windows XP.Symbolic links operate transparently for most operations: programs which read or write to files named by a symbolic link will behave as if operating directly on the target file. However, programs that need to handle symbolic links specially (e.g., backup utilities) may identify and manipulate them directly.
How to Open rar file or Extract rar files under Linux or UNIX
RAR files are in compressed archive format, if you have downloaded rar files from the Internet, you need to unpack or unrar them (extract rar files).RAR is a proprietary file format for data compression and archiving, developed by Eugene Roshal.Under Linux and UNIX, use command called unrar. By default unrar is not being installed on Linux, FreeBSD or UNIX oses. You can install unrar command with the help of apt-get or yum command.
Install unrar command
Under Debian Linux, you need to type apt-get as follows to install unrar program:
# apt-get install unrar
If you are using Fedora core Linux then use yum command as follows (see discussion below):
# yum install unrar
If you are using FreeBSD, use:
# pkg_add -v -r unrar
If any of above, methods is not working for you, download binary package from official rarlab site:
$ cd /tmp
$ wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz
Untar file
$ tar -zxvf rarlinux-3.6.0.tar.gz
Both unrar and rar commands are located in rar sub-directory. Just go to rar directory:
$ cd rar
$ ./unrar
Now copy rar and unrar to /bin directory:
# cp rar unrar /bin
How to use unrar
unrar command supports various options below are common options that you need to use everyday.
Task: To open rar (unpack) file in current directory type command:
$ unrar e file.rar
Please note that replace file.rar filename with your actual filename.
Task: List (l) file inside rar archive:
$ unrar l file.rar
Task: To extract (x) files with full path type command:
$ unrar x file.rar
(D) To test (t) integrity of archive, file type command:
$ unrar t file.rar
Installing vnstat
Step 1: Installing vnstat
cd /usr/local/src
wget http://humdi.net/vnstat/vnstat-1.6.tar.gz
tar -zxvf vnstat-1.6.tar.gz
cd vnstat-1.6
make && make install
vnstat -u -i eth0
Step 2: Making vnstat root only
chmod 700 /usr/bin/vnstat
chmod 700 /var/lib/vnstat/ -R
Step 3: Now you can check the stats, use help for possbible commands
vnstat --help
How to determine which sevices are enabled at boot time in linux
How do I find out which services are enabled at Boot under Ubuntu/CentOS/RHEL/Fedora Linux? How can I disable a service which is not needed or I dont want to run every time the linux machine starts?
Open terminal and login as root user.
Type the following command to list all services which are enabled at boot:
#chkconfig --list | grep $(runlevel | awk '{ print $2}'):on
Sample output:
acpid 0:off 1:off 2:off 3:on 4:on 5:on 6:off anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off dkms_autoinstaller 0:off 1:off 2:on 3:on 4:on 5:on 6:off haldaemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off hidd 0:off 1:off 2:on 3:on 4:on 5:on 6:off irqbalance 0:off 1:off 2:on 3:on 4:on 5:on 6:off kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off lighttpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off lm_sensors 0:off 1:off 2:on 3:on 4:on 5:on 6:off lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off mcstrans 0:off 1:off 2:on 3:on 4:on 5:on 6:off mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off messagebus 0:off 1:off 2:off 3:on 4:on 5:on 6:off microcode_ctl 0:off 1:off 2:on 3:on 4:on 5:on 6:off mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off named 0:off 1:off 2:on 3:on 4:on 5:on 6:off netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off pcscd 0:off 1:off 2:on 3:on 4:on 5:on 6:off psacct 0:off 1:off 2:on 3:on 4:on 5:on 6:off readahead_early 0:off 1:off 2:on 3:on 4:on 5:on 6:off restorecond 0:off 1:off 2:on 3:on 4:on 5:on 6:off rhnsd 0:off 1:off 2:on 3:on 4:on 5:on 6:off rpcgssd 0:off 1:off 2:off 3:on 4:on 5:on 6:off rpcidmapd 0:off 1:off 2:off 3:on 4:on 5:on 6:off sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off setroubleshoot 0:off 1:off 2:off 3:on 4:on 5:on 6:off smartd 0:off 1:off 2:on 3:on 4:on 5:on 6:off snmpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off yum-updatesd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
The first column of above output is the name of a service which is currently enabled at boot. You need to review each service.
Task: Disable services
To stop service, enter:
# service {service-name} stop # service vmware stop
To disable service, enter:
# chkconfig {service-name} off # chkconfig vmware off
You may also use ntsysv command to manage all services.
A note about outdated insecure service
All of the following services must be disabled to improve server security:
- Inetd and Xinetd (inetd xinetd) - Use direct services configured via SysV and daemons.
- Telnet (telnet-server) - Use ssh
- Rlogin, Rsh, and Rcp ( rsh-server ) - Use ssh and scp.
- NIS (ypserv) : Use OpenLDAP or Fedora directory server.
- TFTP (tftp-server) : Use SFTP or SSH.
To delete all of the service enter:
# yum erase inetd xinetd ypserv tftp-server telnet-server rsh-serve
How to view or display a logfile in real time on screen in linux
How do I see the log file in real time including all incoming logs as well?
You can use the tail command in linux command line which outputs the last part of files in real time including all incoming logs to a file. So you can view the last parts of your logs file (like access logs for the server) using this in real time!
Note: you may need to login as root user to view log files.
Command
tail -f file-name command
If your log file name is /var/log/lighttpd/access.log, enter:
tail -f /var/log/lighttpd/access.log
If your php log file name is /var/log/lighttpd/scripts.log, enter
tail -f /var/log/lighttpd/scripts.log
You will get a scrolling view of the /var/log/lighttpd/scripts.log for all incoming entries on screen. To stop simply hit CTRL+C.
Ubuntu / Debian Linux: Install Monit Linux Server Monitoring Utility
How do I install monit to monitor my server under Debian / Ubuntu Linux?
Monit is a utility for managing and monitoring processes, files, directories and devices on a Debian / Ubuntu Linux server system. Here a few common uses of monit:
- Monit can start a process if it does not run
- Restart a process if it does not respond
- Stop a process if it uses to much resources etc
How do I install monit utility for monitoring services?
Type the following command as the root user:
$ sudo apt-get update $ sudo apt-get install monit
Configure monit
Open monit configuration file /etc/monit/monitrc using vi text editor or nano command in linux:
# vi /etc/monit/monitrc
OR
# nano /etc/monit/monitrc
You need to set following parameters:
set daemon 120 set logfile syslog facility log_daemon set mailserver localhost # primary mailserver set alert vivek@nixcraft.com # receive all alerts
The next step is to save and close this file. Where,
- set daemon 120 : Start monit in background as daemon and check the services at 2-minute intervals.
- set logfile syslog facility log_daemon : Log messages in /var/log/messsages file
- set mailserver localhost : Send email alert via localmail server such as sendmail. Set list of mailservers for alert delivery. Multiple servers may be specified using comma separator. By default monit uses port 25 - it is possible to override it with the PORT option.
- set alert vivek@nixcraft.com : You can set the alert recipients here, which will receive the alert for each service. The event alerts may be restricted using the list.
Now open /etc/default/monit file to turn on monit service:
# vi /etc/default/monit
OR
# nano /etc/default/monit
Set startup to 1, so monit can start:
startup=1
Save and close the file.
Start the monit Linux monitor tool / service:
# /etc/init.d/monit start
Enable Read Only Mode on a MySQL server
Here are some useful options that can prevent writing to MySQL databases, while retaining the right reading.
The activation of these features may be particularly interesting in the case of a change of server. You can then export and import all data from one server to another, being sure to maintain data integrity. As for customers, they can only read data.
1. Method by changing a variable server
To do this, connect to the server with root user:
mysql-h localhost-u root-p
and run the command:
mysql> set GLOBAL read_only = true;
The data in all databases are accessible only for reading. Note that root guard on the other hand always have the right to write.
Example of inserting data with a simple user:
mysql> INSERT INTO foo VALUES ( 'tata2');
ERROR 1290 (HY000): The MySQL server is running with the-read-only
option so it can not execute this statement
To disable this mode, you can then run the following command:
mysql> set GLOBAL read_only = false;
2. Method of positioning locks
There is also a second method is to put locks via:
mysql> FLUSH TABLES WITH READ LOCK;
The latter will then close all open tables and locks all the reading tables and bases.
At this time, applications that wish to make an entry will be queued until the unlock command:
mysql> UNLOCK TABLES;
It will be possible to see a list of requests waiting in the listing process as follows:
mysql> SHOW processlist;
| 5 | root | localhost | test | Query | 160 | Waiting for release of readlock | INSERT INTO foo VALUES ( 'tata2') |
Conclusion
The first method seems more adapted when transferring data from one MySQL server to another, while the second plutût it will be used in case of a backup cold.
How to Stop/Restart Lighttpd Web Server in Debian / Ubuntu / FreeBSD linux
/etc/init.d/lighttpd is a script under Linux to stop / restart lighttpd web server.
To stop lighttpd:
Use the following command to stop lighttpd:
# /etc/init.d/lighttpd stop
To restart lighttpd:
Just type the following command to restart lighttpd:
# /etc/init.d/lighttpd restart
To start lighttpd:
# /etc/init.d/lighttpd start
Debian / Ubuntu Linux Start lighttpd
# /etc/init.d/lighttpd start
Debian / Ubuntu Linux - Stop lighttpd
# /etc/init.d/lighttpd stop
Debian / Ubuntu Linux - Restart lighttpd
# /etc/init.d/lighttpd restart
FreeBSD Start lighttpd web server
# /usr/local/etc/rc.d/lighttpd start
FreeBSD - Stop lighttpd webserver
# /usr/local/etc/rc.d/lighttpd stop
FreeBSD - Restart lighttpd webserver
# /usr/local/etc/rc.d/lighttpd restart
In case if you don't have init script, type the following:
# killall lighttpd
Ubuntu Linux Start / Restart / Stop Apache 2.2 Web Server
Q. How to restart or stop Apache 2.2 web server under Ubuntu Linux?
Task: Start Apache 2.2 Server
# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start
Task: Restart Apache 2.2 Server
# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart
Task: Stop Apache 2.2 Server
# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop