How to upload the artifacts in Sonatype Nexus | Tutorial

 artifacts-in-sonatype-nexus
1. Upload Artifacts using NEXUS GUI
https://books.sonatype.com/nexus-book/reference/using-sect-uploading.html
2. Upload Artifacts using Maven pom.xml using “mvn deploy”
Update your pom.xml with following…
<distributionManagement>
  <repository>
  <id>deployment</id>
  <name>Internal Releases</name>
  <url>http://uvo1ppw4qmimuo3p1tg.vm.cld.sr:8081/nexus/content/repositories/releases/</url>
  </repository>
  <snapshotRepository>
<id>deployment</id>
<name>Internal Releases</name>
<url>http://uvo1ppw4qmimuo3p1tg.vm.cld.sr:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
Update your setting.xml with following
<servers>
<server>
<id>deployment</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
3. Upload Artifacts using Linux Commands
> curl -v -u admin:admin123 –upload-file pom.xml http://localhost:8081/nexus/content/repositories/releases/org/foo/1.0/foo-1.0.pom
> curl -v \
-F “r=releases” \
-F “g=com.acme.widgets” \
-F “a=widget” \
-F “v=0.1-1” \
-F “p=tar.gz” \
-F “file=@./widget-0.1-1.tar.gz” \
-u myuser:mypassword \
http://localhost:8081/nexus/service/local/artifact/maven/content
4. Upload Artifacts using mvn commands
Upload Artifacts using Maven “deploy-file” Deployment
Example without a pom file:
mvn deploy:deploy-file -DgroupId=com.somecompany -DartifactId=project -Dversion=1.0.0 -DgeneratePom=true -Dpackaging=jar -DrepositoryId=nexus -Durl=http://localhost:8081/nexus/content/repositories/releases -Dfile=target/project-1.0.0.jar
With a pom file:
mvn deploy:deploy-file -DgroupId=com.somecompany -DartifactId=project -Dversion=1.0.0 -DgeneratePom=false -Dpackaging=jar -DrepositoryId=nexus -Durl=http://localhost:8081/nexus/content/repositories/releases -DpomFile=pom.xml -Dfile=target/project-1.0.0.jar
With a Zip file:
> mvn deploy:deploy-file -DgroupId=com.fanniemae.securitiesprocessor -DartifactId=sp_adapter_mbs -Dversion=0.0.1-SNAPSHOT -Dpackaging=zip -Dfile=sp_adapter.zip -DrepositoryId=deployment -Durl=http://nexus-server:8081/nexus/content/repositories/snapshots/
Note: You need to update your setting.xml with following. where as The “repositoryId” parameter is not a Nexus repository ID, it is the ID of a server section in your settings.xml file which has then credentials needed for deployment.
<servers>
<server>
<id>nexus</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
Tagged : / / / / / /

gsh – Run linux commands on many other linux server at once

gsh-run-linux-commands

gsh – Run linux commands on many other linux server at once

Group Shell (also called gsh) is a remote shell multiplexor. It lets you control many remote shells at once in a single shell. Unlike other commands dispatchers, it is interactive, so shells spawned on the remote hosts are persistent.

GSH is a pluggable version of DSH (Distributed Shell) written in Python. Both a module and a command-line tool for running a shell command over multiple machines are included. GSH can be extended by adding new host loaders as well as hooking into various stages of the runtime.

It requires only a SSH server on the remote hosts, or some other way to open a remote shell.
gsh allows you to run commands on multiple hosts by adding tags to the gsh command.

e.g > gsh tag “remote command”

Important things to remember:
/etc/ghosts contains a list of all the servers and tags. gsh is a lot more fun once you’ve set up ssh keys to your servers

gsh [OPTIONS] SYSTEMS CMD…
SYSTEMS is a combination of ghost macros. See ghosts(1).

CMD is the command to run
-h, –help Display full help
-d, –debug Turn on exeuction debugging reports
-h, –no-host-prefix Does not prefix output lines with the host name
-s, –show-commands Displays the command before the output report
-n, –open-stdin Leaves stdin open when running (scary!)
-l, –user USER SSH’s to the host as user USER
-r, –run-locally Run commands locally (replaces $host with host)
-o, –self-remote Run locally instead of over SSH for local host
-V, –version Report the version and exit

You set up a /etc/ghosts file containing your servers in groups such as web, db, RHEL4, x86_64, or whatever (man ghosts) then you use that group when you call gsh.

How to run the gsh?
> gsh linux “cat /etc/redhat-release; uname -r”

You can also combine or split ghost groups, using cpanel+vps or web-RHEL4, for example.

Here’s an example /etc/ghosts file:
# Machines
 #
 # hostname OS-Version Hardware OS cp security
 linuxbrigade.com debian6 baremetal linux plesk iptables
 linuxbrigade.com centos5 vps linux cpanel csfcluster
 linuxbrigade.com debian7 baremetal linux plesk iptables
 linuxbrigade.com centos6 vps linux cpanel csfcluster
 linuxbrigade.com centos6 vps linux cpanel csfcluster
 linuxbrigade.com centos6 vps linux nocp denyhosts
 linuxbrigade.com debian6 baremetal linux plesk iptables
 linuxbrigade.com centos6 baremetal linux cpanel csf
 linuxbrigade.com centos5 vps linux cpanel csf

Reference url

http://www.linuxbrigade.com/run-the-same-command-on-many-linux-servers-at-once/
http://linux.die.net/man/1/gsh
https://github.com/gmjosack/gsh
http://outflux.net/unix/software/gsh/
http://outflux.net/unix/software/gsh/gsh.html

Tagged : / / / / / / / / / /

Linux Commands for Administrator | Linux Admin Commands Reference

linux-commands-administrators

su: Acquiring Superuser Status
# su  :- Acquire  Superuser after entering password but home directory does not change
# su – l :– Acquire Superuser access after password but home  directory change to ROOT
# su  – henry : – To  Login and Recreate a user environment
# sudo -s root -c “/bin/bash -l”

passwd – Changing any Password
# passwd henry
stat <fileName>

ulimit – Setting Limits on file size
ulimit command impost a restriction on the maximum size of a file that a user is permitted to create
# ulimit 20971510                             This is often placed in /etc/profile. Measured in 512 byte blocks

umask – Please refer user manual

Source
The source command in shell is used to execute commands from a file in the current shell. This is useful to load function or variables stored in another file.
# source filename
# source /path/to/file

locate

To locate any files in system. This works based on updatedb.
# locate
# updatedb     Run as a root.File location is /var/lib/mlocate/mlocate.db

which
shows the full path of (shell) commands

od
od command dumps a file in octal, decimal, and other formats.

# od -c special-chars.txt

# od -bc special-chars.txt

chkconfig
chkconfig command is used to setup, view, or change services that are configured to start automatically during the system startup.

The –list option displays all the services with the current startup configuration status.
# chkconfig –list
To view only the services that are configured to be started during system startup, do the following. Please note that this assumes that your system startup level is 3
# chkconfig –list | grep 3:on
To display the current settings for a selected service only, use chkconfig –list followed by the name of the service:
# chkconfig –list service_name

To enable a service in runlevels 2, 3, 4, and 5, type the following at a shell prompt as root.
# chkconfig service_name on
To disable a service in runlevels 2, 3, 4, and 5, type the following at a shell prompt as root.
# chkconfig service_name off

# chkconfig network –level 3 && echo “Network service is configured for level 3”
# chkconfig network –level 1 && echo “Network service is configured for level 1”

To view the startup configuration of a particular service, grep the output of ‘chkconfig –list’ for that service.
# chkconfig –list | grep network

Add a new Service to the Startup
# chkconfig –add iptables

To remove it from the startup list, use the –del option as shown below.
# chkconfig –del ip6tables

How to install services?

Step 1. Copy the script into /etc/init.d/ such as /etc/init.d/httpd
Step 2. chkconfig --add httpd

http://bitnami.org/article/how-to-install-services-on-linux

service
# service network restart
OR
# /etc/init.d/network restart

To start Linux network service:
# service network start

To stop Linux network service:
# service network stop

date – Setting the system Date
# date MMDDhhmm

groupadd
# groupadd –g 241 dba               The command place entry in /etc/group which can also insert manually(dba:x:241). 241 is GID of dba

useradd
# useradd –u 210 –g dba –c “The RDBMS” –d /home/oracle –s /bin/bash –m username

usermod
# usermod –s /bin/csh username

userdel
# userdel username

shutdown
# shutdown 17:30                         Shutdown at 17:30
# shutdown –r now                     Shutdown immediately and reboot
# shutown –r 17:30                      Shutdown immediately and reboot at 17:30
# shutown –h now                       Shutdown immediately and halt
# shutown –h 17:30                     Shutdown at 17:30
# shutdown –c                               Cancel the shutdown
Reboot / Poweroff / halt

df
The df (disk free) command lets you see if file systems are full.

  • To see how much free space is in all file systems (including mounted ones), use df
  • To see how much free space is in all file systems with names containing “dev”, use df | grep dev
  • To see how much free space is in your home file system, use df /home
  • To see how much free space is in the file system “tmp”, use df /tmp
  • To see if there is enough free space on the machine, check the output from the following

# df /usr,
# df /var
# df -k /tmp /home                                          -k Reports in units of KB
# df –h / /usr                                                       -h reports in MB, GB

du -Disk usage
# du  /home/sales/tml
# du –s /home/*                                               -s options for summary disk usage information for tml directory
# du –sh /home                                                 -h options for reports in MB , GB
# find /home –size +1024 –print                                     Files above 1MB
# find /home –size +1024 –size -4096 – print             Files above 1Mb and below 4MB

mount / unmount

Using file for incremental Backup
# tar –cvf /dev/rct0 `find /home –type f –newer .last_time –print`
# touch .last_time
# tar –cvf /dev/rct0 /home > homelist `date “+%d%b%y”`

xrags

xargs vs. exec {}

Remote machine Login: telnet, rlogin
telnet
rlogin

Secure Login with password: ssh
ssh

Remote login without Password: rsh
rsh

File Transfer: ftp, rcp, scp
rcp

scp

ftp
ftp rajesh-servers – How to Login
Directory Commands:
# cd [directory] Changes to the specified directory on the remote system.
# dir Displays a long listing of files on the remote system.
# ls Displays a short listing of the files on the remote system.
# lcd Changes the working directory on the local system.
# pwd Displays the working directory on the remote system.
File Transfer Commands:
# get [filename] Downloads a single file from the remote system.
# put [filename] Uploads a single file to the remote system.
# mget [file…] Downloads multiple files from the remote system.
# mput [file…] Uploads multiple files to the remote system.

Generic troubleshooting tips

  • Use tail –f to watch log file in real time, advantage is simple you can spot error or warning message in real time.
    tail –f /path/to/log/file
    Example(s):
    # tail –f /var/log/maillog
  • Use telnet command to see if you get response or not. Sometime you will also see some informative message:
    telnet ip port

Example(s):
# telnet localhost 53
# telnet localhost 25

  • Make sure you can see PID of your service.
    pidof service-name
    cat /var/run/service.pid

    Example(s):
    # pidof sshd
    # cat /var/run/sshd.pid
  • You need to make sure that your DNS server or third party DNS server (ISP) is accessible. This is an important step, as many network services depend upon DNS; especially sendmail/postfix or Squid etc for example. Run dig or nslookup. No timeout should occurred.

    # dig your-domain.com
    # nslookup gw.isp.com
    # more /etc/resolv.conf

Performance /  Memory / CPU / Process check
ps – Read user manual

w username –  Find Out Who Is Logged on And What They Are Doing. w command displays information about the users currently on the machine, and their processes.

top
The top program provides a dynamic real-time view of a running system i.e. actual process activity. By default, it displays the most CPU-intensive tasks running on the server and updates the list every five seconds.

uptime
tell How Long The System Has Been Running

free – Memory Usage
The command free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel.
# free –m                                                            Display free memory size in MB
# free -t –m                                                        Displays a line containing the totals memory in MB

vmstat

Linux Performance Monitoring using iostat, mpstat and vmstat

iostat

pmap

mpstat 

# strace & truss – Debug the Execution of a Program in Linux
Trace the Execution of an Executable
# strace ls

Save the Trace Execution to a File Using Option -o
strace -o output.txt ls

Execute Strace on a Running Linux Process Using Option -p
# ps -C firefox-bin To get the process id
# sudo strace -p 1725 -o firefox_trace.txt

Print Relative Time for System Calls Using Option -r
# strace -r ls

Networking troubleshooting tips

Hostname verification or setup tools

  • hostname : To get hostname of server.
  • hostname –s : To get FQDN hostname of server
  • more /etc/sysconfig/network : To setup hostname and networking can enable or disabled.
  • dnsdomainname : List or setup domainname.
  • more /etc/hosts : Make sure at least localhost entry do exist.

Ethernet configuration tools

service network reload|restart|stop|start : To reload (after changed made in ip config file)|restart|stop|start network interface with all properties.

route
The route command allows you to add static routes to the routing tabling.

traceroute (tracert in Windows)
Traceroute displays the routers that are passed through to reach the destination.

dmesg
When the system boots up, it prints number of messages on the screen that displays information about the hardware devices that the kernel detects during boot process.
These messages are available in kernel ring buffer and whenever the new message comes the old message gets overwritten. You could see all those messages after the system bootup using the dmesg command.

# dmesg | more
# dmesg | grep Memory
# dmesg  | grep eth

ifconfig
The ifconfig command is used to display the local interface configuration (winipcfg for Windows) and to modify the configuration.
ifconfig eth0 up|down : To enable|disable network interface

netstat
The network status command netstat displays status information about the network interfaces on the host machine. Netstat command displays the network related information such as network connections, routing tables, interface statistics.
-a                Show both listening and non-listening sockets
-n                prints the numeric forms of IP address

# netstat -ain                                  Local interface status
# netstat -rn                                    Routing table information
# netstat –an                                  Display Active Internet Connections and domain sockets using netstat
# netstat -tap                                 Display Active Connections with Process ID and Program Name
# netstat –-route                          Display Routing Table
# netstat –statistics –raw         Display RAW network statistics
# netstat –tcp –numeric           List of TCP connection to and from the machine.
netstat -tuplin                                UNIX

iptables

To know which ports are running in the machine.
ping
The ping command allows you to determine that the:

  • TCP/IP stack is configured properly
  • Network interface card is configured properly
  • Default gateway and subnet mask is configured properly
  • Domain name services is configured properly.

# ping ipaddress to check if the ip address in connected with network and if host is alive or dead
# ping 127.0.0.1/localhost – to check TCP/IP services is running properly or not. Checks that your TCP/IP stack is working properly up to the NIC. If this fails, check to see if you have TCP/IP services loaded.
# ping “IP address of default gateway” – Checks that the NIC is working on the local subnet by pinging the local side of the default gateway which is a router. If this fails, check that TCP/IP is bound to the NIC. Then check that the NIC’s IRQ, and base address are set properly both on the card itself and in the operating system’s interface configuration.
# ping “domain name” if DNS name is correctly configured. If it fails, check that the DNS server’s IP address is entered in properly in the TCP/IP configuration.

arp
address resolution protocol

# arp   – To see the IP to MAC address translation table
# arp -a  -Use this command to see the IP to MAC address translation table if you are having problems connecting to other network hosts. It is a dynamic cache which updates every 120 seconds.

# more /etc/modules.conf : To see your network card configuration alias for eth0 exists or not.
# lsmod : To list loaded modules (read as drivers), here you need to see that eth0 module is loaded or not, if not loaded then use insmod to insert (load) driver.
# dhclient : Dynamic Host Configuration Protocol Client, run this if your Ethernet card is not getting ip from DHCP box on startup; this command does by default shows useful information.

To see if service blocked because of access control
# iptables –n –L : To list all iptable rules; useful to see if firewall blocks service or not.
# service iptables stop|start : To start|stop iptables
# more /etc/xinetd.conf

sar
sar is an excellent monitoring tool that displays performance data of pretty much every resource of the system including CPU, memory, IO, paging, networking, interrupts etc., Sar Collects, Reports (displays) and Saves the performance data.

# sar –u | more         Display CPU Statistics using Sar Command
# sar –d | more         Display Disk IO Statistics using sar command
# sar -n DEV | more Display networking Statistics using sar command
# sar -n SOCK |more Display networking Statistics using sar command
# sar -n DEV -f /var/log/sa/sa24 | more   To display the network counters from the 24th
# sar 4 5                                             You can also display real time usage using sar

lsof
lsof stands for “ls open files”, which will list all the open files in the system. The open files include network connection, devices and directories. The output of the lsof command will have the following columns:

COMMAND process name.
PID process ID
USER Username
FD file descriptor
TYPE node type of the file
DEVICE device number
SIZE file size
NODE node number
NAME full path of the file name.

# lsof | more              View all open files of the system
# lsof | wc -l                How many files are open in the system at any given point
# lsof –u ramesh       View open files by a specific user. A system administrator can use this command to get some idea on what users are executing on the system.
# lsof /bin/vi               it displays all users who are currently using vi

Some external Tools
iptraf – Real-time Network Statistics
tcpdump  – Detailed Network Traffic Analysis
Nagios – Server And Network Monitoring
Cacti – Web-based Monitoring Tool
KDE System Guard – Real-time Systems Reporting and Graphing
Gnome System Monitor – Real-time Systems Reporting and Graphing
nmap – scan your server for open ports.
lsof – list open files, network connections and much more.
ntop web based tool – ntop is the best tool to see network usage in a way similar to what top command does for processes i.e. it is network traffic monitoring software. You can see network status, protocol wise distribution of traffic for UDP, TCP, DNS, HTTP and other protocols.
Conky – Another good monitoring tool for the X Window System. It is highly configurable and is able to monitor many system variables including the status of the CPU, memory, swap space, disk storage,
temperatures, processes, network interfaces, battery power, system messages, e-mail inboxes etc.
GKrellM – It can be used to monitor the status of CPUs, main memory, hard disks, network interfaces, local and remote mailboxes, and many other things.
vnstat – vnStat is a console-based network traffic monitor. It keeps a log of hourly, daily and monthly network traffic for the selected interface(s).
htop – htop is an enhanced version of top, the interactive process viewer, which can display the list of processes in a tree form.
mtr – mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.

yum
Rsync
rpm – Refer Cheat Book

Some Well known System services
QUICK DNS Flush                             /etc/rc.d/init.d/nscd restart
/Proc file system – Various Kernel Statistics
# cat /proc/cpuinfo
# cat /proc/meminfo
# cat /proc/zoneinfo
# cat /proc/mounts

Questions
What is MASK in output of ifconfig
Understand the output of ifconfig in linux such as RX packets and TX packets
Set ip address using commands line

Change Host name in RHEL
Changes should be made in the following files.
/etc/hosts
/etc/sysconfig/network

For finding your java process
jps -v      For finding your java process.
jstack PID  To Get stack of threads inside jvm

If application running under different user than yourself
sudo jps -v
sudo jstack 6172

QUICK DNS Flush
/etc/rc.d/init.d/nscd restart
/etc/rc.d/init.d/nscd restart
Reference
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch04_:_Simple_Network_Troubleshooting
http://www.cyberciti.biz/tips/linux-security.html
http://www.cyberciti.biz/tips/list-of-linux-troubleshooting-commandstools-part-1.html
http://www.princeton.edu/~unix/Solaris/troubleshoot/index.html
http://www.techbooksforfree.com/intro_to_data_com/page252.html
http://www.scmgalaxy.com/unix-linux/linux-performance-monitoring-using-iostat-mpstat-and-vmstat.html

http://www.tecmint.com/20-advanced-commands-for-linux-experts/

Tagged : / / / / / / / / / / / /

Linux Commands for User | Linux User Commands Reference

linux-commands-user

General Commands Not Used Frequently
cal – The Calender
bc – The Calculator
file – knowing the file types
cmp – Comparing two files.
comm – Common in two files
dos2unix and unix2dos – Converting between dos and unix
stat – Display file or file system status such as Access, Modify,Change, users and more
# stat <fileName> unix Command

General Commands Frequently Used
Script – recording your session
Passwd – change your password
Echo  – Displaying the message
Printf – Displaying the message
who – Who are the Users
who am I – To know my user name
uname – Knowing your machine characteristics
# uname –a  – To Print all info.
tty – knowing your terminal
pwd – Checking Current Directory
cd – changing the current Directory
mkdir – Making directories
rmdir – removing directories
ls – Listing Directory Contents
# ls –F – Marks executables with *, directories with / and symbolic links with @ at the end of file name.
# ls – a – Shows all filesnames including beginning with a dot.
# ls –R – Recursive display list of files and folders
# ls -1 – one filename in each line
# ls –l long listing + time of last file modification
# ls –t Sorts filenames by last modification time
# ls –u – Sorts filenames by last access time
# ls –I – Displays inode number
# ls –lc – Time of last inode modifcation

Cat – Displaying and creating Files
# cat filename – Displaying file contents
# cat –n filename – Displaying file contents with line numbers
# cat > filename – To Create a file name

More – Paging Output
# more filename – To to display the filename contents

Less – Paging Output

wc – Counting lines, Words and Characters
# -l – Option counts only the number of lines
# -w – Option counts only the words.
# -c – Options counts only the characters.

cp – copying a files
Options
# -p – Copy the files including preserve the mode, ownership and permissions.
# -R – Copying Directory Structure

gzip and gunzip – Compressing and Decompressing Files
# gzip filename
# gzip –l – To find out how much of the compression was archived.
# gzip –d filename – To Decompress a file
# gunzip filename – To Decompress a file
# gzip –R dir – To Compress Recursive

Tar – The archival Program
# -c – To create a archive
# -x – Extract files from archive
# -t – Display fils in archive
# -v – verbose
# -f – name of the arch filename .tar
# tar –cvf filename.tar filename1 filename2
# tar –xvf filename.tar

Create tar and gzip
# tar cvf – foodir | gzip > foo.tar.gz

Un-tar and gunzip
# tar -zxvf apache-activemq-5.1.0-bin.tar.gz

Un-tar and uncompress using gunzip
# gunzip -c apache-activemq-5.1.0-bin.tar.gz | tar xvf –
or alternatively:
# gunzip apache-activemq-5.1.0-bin.tar.gz | tar xvf –

File Attributes
chmod – Changing File Permission

Abbreviations Used by chmod

Category Operation Permission Assigned Number
u -user + – Assigns Permission r – Read permission 4
g -group –  – Assigns Permission w – Write Permission 2
o – other = – Assigns Permission x – Execute Permission 1
a –all(ugo)

Example:
# chmod u+x filename
# chmod u+x filename
# chmod ugo+x filename
# chmod u+x filename1 filename2 filename3
# chmod a-x,go+r filename
# chmod 566 filename
# chmod 755 filename
# chmod –R 755 .
# chmod –R a+x *

Chown – Changing File Ownership
# chown username filename
More example needed.

Shell’s Wild-Cards

Wild-Card Matches
* Any numbers of characters including none
? A single character
[ijk] A single character – either I,j or k
[x-z] A single character that is within the ASCII range of the characters x and z
[!ijk] A single character that is not an I,j, or k
[!x-z] A single character that is not within the ASCII range of the characters x and z
 

Ps – Process Status
Options to ps

POSIX Options Significance
-f Full listing showing the PPID of each process
-e or –A All Process including user and Systems
-u usr Process of user usr only
-a Processes of all users excluding processes not associated with terminal
-l A long listing showing memory-related information

Example
# ps -ef
# ps –u sumit
# ps –a
# ps –e
# ps -A – ps command will report a snapshot of the current processes. To select all processes use the -A
# ps -Al – Show Long Format Output
# ps -AlF – To turn on extra full mode (it will show command line arguments passed to process):
# ps axu – Print All Process On The Server
# ps -U vivek -u vivek u – See Every Process Running As User Vivek
# ps -p 55977 -o comm= – Display The Name of PID 55977
# ps -auxf | sort -nr -k 4 | head -10 – Find Out The Top 10 Memory Consuming Process
# ps -auxf | sort -nr -k 3 | head -10 – Find Out top 10 CPU Consuming Process

# $! – Store the PID of the last background jobs
# echo $$  – To Know the PID of current Shell
# echo $SHELL – To Know the Current Shell
# System process easily identifies the ? in the TTY coloumn.
# Mechanism of Process Creation
Fork
Exec
Wait

& and nohup – Ruunning jobs in background
# nohup sort emp.lst $

nice – Job execution with low priority
Kernel decides how much processor time is required for a process based on the nice value. Possible nice value range is: -20 to 20. A process that has a nice value of -20 is very high priority. The process that has a nice value of 20 is very low priority.
Use ps axl to display the nice value of all running process as shown below.
# ps axl
# nice command is used with & operator to reduce the priority of jobs
# nice script.sh &
# ./nice-test.sh &                             Default the nice value of 0
# nice -10 ./nice-test.sh &            Nice value is 10                 Low priority.
# nice –10 ./nice-test.sh &          Nice value is -10                High priority.

Kill – killing the process
# kill PID
# kill PID1 PID2 PID3
# kill $i – Killing the last background process
# kill –s KILL PID – recommended way for killing (SIGKILL)
# kill -9 PID – same as above but not recommended. (SIGKILL)
# kill -9 $$  -$$ store the PID of current shell
# kill –s KILL 0 – kill all the process including the login shell.
# kill –l – To View the list of all signal names and numbers that are available on your machine.
# kill %1 – Kill first background jobs

Jobs
List the background jobs in following fashion
[3] +       running                                command
[1] –        running                                command
[2]          running                                command

bg – Convert Jobs to background
# if you have invoked a command and the prompt has not yet return, you can suspend the job by pressing Ctrl-Z. Observe that job has not been terminated yet; its onl y suspended (“stopped”). Now you can use bg command to push the current foreground job in the background.
# bg %2 – Sends second job to background
# bg %sort – Sends sort job to background

fg – bring background job to foreground
# fg – To bring most recent job to forground
# fg %1 – Bring First job to foreground
# fg %2 – Bring second job to foreground
# fg %sort – Bring sort job to foreground

at – On time execution
# at 14:08
at > script.sh
[ctrl-d]

Batch – execute when system resources are available
# batch < script.sh

Cron – Schedule and run jobs periodically
# crontab –e – To Edit the cron tab
# crontab –l – To Display the cron tab
# crontab cron.tx – cron.txt contains cron commands
# crontab –r – To Remove the cron

Format of crontab – TODO

Customizing the environment

# set – set statemtent display a complete list of all environment variable
# PATH =$PATH:/usr/xpg4/bin – Adding new value to old values
# PS1 =”C> “ – To Change the prompt
# PS1=’[$PWD] ‘ – To Change the prompt to pwd
# alias cp=”cp –I” – To Set the alias in bash
# history – To See the history
# IFS – Field Separators for commands and arguments
# !! – Repeat Previous commands
# !2 – Repeat commands 2 from history output
# !-2 – Execute the commands prior to previous one
# !v – Execture very last commands beginning withg v
# $_ – Using last arugement of previous commands
# mkdir raj
# cd $_

ln – Hard Links and Softlinks
# ln /usr/bin/perl  /usr/local/bin/perl – To create a hard links from src to dest
# ls –I  – To Display the node number of files
# ln –s /usr/bin/perl  /usr/local/bin/perl – To Create a soft link

umask – default file and directory permission
# When you create a files and directories, the permission assigned to them depends on rge system’s default setting..
# unix has default 666 for regular files & 777 for directories
# umask –ENTER
# 022
This is an octal number which has to be subtracted from system default to obtain the actual default. This becomes 644 (666-022) for ordinary files and 755 ( 777 -022) for directories.
# User can set the umask such as umask 023.

touch – Changing the time stamp
# touch emp.lst – Create a file name called emp.lst
# touch 02161430 emp.lst – To Change the time stamp of file for MMDDhhmm format
# touch –a 02161430 emp.lst – To Change the access time stamp of file for MMDDhhmm format
# touch –m 02161430 emp.lst – To Change the modification time stamp of file for MMDDhhmm format

find – Locating files

Expression Used by find.

Expression Use
-inum n Having inode number n
-type x if of type x can include files, directories or symbolic link
-type f If an ordinary file
-perm nnn If octal permission match nnn completely
-links n If having n links
-user usname If owner by usname
-group gname If owned by group gname
-size +x[C]
-mtime –x If modified in less than x days
-newer filename If modified after filename
-mmin –x If modified in less than x minutes
-atime +x If accessed in more than x days
-amin +x If accessed in more than x minutes
-name filename Filename
Action Significance
-print Prints selected file on standard output
-ls Executes ls –lids commands on selected files
-exec cmd Executes UNIX command cmd followed by {} \;
-ok cmd Like –exec, except that command is executed after user confirmation

Example

Change File Permissions Recursively
# find . -type f -exec chmod 644 {} \;
# find . -type d -exec chmod 755 {} \;
# find . -name Configuration.php -exec chmod 666 {} \;

Find files modified in the last 48 hours, and in current folder and one level below
# find -maxdepth 2 -type f -mtime -2

To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:
# find /directory_path -mtime -1 –print

To find all files with regular file types only, and modified in the last 24 hours (last full day) in current directory and its sub-directories:
# find /directory_path -type f -mtime -1 –print
# find . -type f -mtime -1 –print

To find all files that are modified today only (since start of day only, i.e. 12 am), in current directory and its sub-directories:
# touch -t `date +%m%d0000` /tmp/$$
# find /tmefndr/oravl01 -type f -newer /tmp/$$
# rm /tmp/$$

To find all files in /home/user/demo directory
# find /home/user/demo -type f –print

To find all files in /home/user/demo directory with permission 777, enter:
# find /home/user/demo -type f -perm 777 –print

Apply new permission using the -exec option as follows:
# find /home/user/demo -type f -perm 777 -print -exec chmod 755 {} \;

To select directories and subdirectories use the following syntax:
# find /var/www/html -type d -perm 777 -print -exec chmod 755 {} \;

This first Linux find example searches through the root filesystem (“/”) for the file named “Chapter1”. If it finds the file, it prints the location to the screen.
# find / -name Chapter1 -type f –print

A nice thing to know is that on Linux systems and modern Unix system you no longer need the -print option at the end of the find command, so you can issue it like this:
# find / -name Chapter1 -type f

This next find command searches through the /usr and /home directories for the file named Chapter1:
# find /usr /home -name Chapter1 -type f

To search in the current directory, and all subdirectories, just use the . character to reference the current directory in your find commands, like this:
# find . -name Chapter1 -type f

This next command searches through the /usr directory for all files that begin with the letters Chapter, followed by anything else. The filename can end with any other combination of characters. It will match filenames such as Chapter, Chapter1, Chapter1.bad, Chapter-in-life, etc.:
# find /usr -name “Chapter*” -type f

This next command searches through the /usr/local directory for files that end with the extension .html. These file locations are then printed to the screen.
# find /usr/local -name “*.html” -type f

To find all directories named build under the current directory, use this command:
# find . -type d -name build

This command searches through the htdocs and cgi-bin directories for files that end with the extension .cgi. When these files are found, their permission is changed to mode 755 (rwxr-xr-x). This example shows that the find command can easily search through multiple sub-directories (htdocs, cgi-bin) at one time.
# find htdocs cgi-bin -name “*.cgi” -type f -exec chmod 755 {} \;

Find and display files last modified les than 90 days ago.
# find . -name “*” -mtime -3 -print

find everything in your home that has been modified more recently than “abc.txt”:
# find $HOME -newer ~joeuser/lastbatch.txt

For finding only files from all directories recursively
# find ./ -type f | wc -l

For finding only files from all directories recursively
# find ./ – type d | wc -l

How to Return a message when a file is not found using find command? OR
Find command return type OR
when the file is not found i want it to return some value OR
# find . -name raj.txt > raj.txt
# counter= `cat abc.txt | wc -l’
# if [$counter -gt 0]
# then
#                echo “File is found”
# else
#                echo “File is not found”
# fi
That’s nice, but what if I want to see the last modification time of these files, or their filesize? No problem, I just add the “ls -ld” command to my find command, like this:
find . -name “*.pl” -exec ls -ld {} \;

Count Total number of files in Directory and Subdirectory
# find . -type f | wc –l

Count Specific extention files in Directory and Subdirectory
# find . -type f -name \*.mnp |wc –l

Count only Directory
# find . -type d | wc –l

head – Displaying the beginning of a file
# head –n 3 filename
# vi `ls –t` | head –n 1` – Opens last modified file for editing

tail – Displaying the end of a file
# tail -3 filename
# tail –f filename             Monitering file live

Cut
# cut –c 6-12,24-32 filename – Cutting column
# cut –d \| -f 2,3 filename            – Cutting fields
# cut –d “|” –f 1,4- filename –To cut out the fields numbered 1,4,5 and 6.

Sort – Ordering a file
Sort Options

Option Description
-tchar Use delimiter char to identify fields
-k n Sorts on nth field
-k m,n Start sort on mth field and end sort on nth field
-k m.n Start sort on nth column of mth field
-u Removes repeated lines
-n Sort numerically
-r Reverse sort order
-m list Merge sorted files in list
-c Checks of file sorted
-o filename Place output in file filename

Examples:
# sort –t”|” –k 2 shortlist
# sort –t”|” –r –k 2 shortlist
# sort –t “|” –k 3,3 –k 2,2 shortlist
# sort –t”|” –k 5.7,5.8 shortlist
# sort numfile
# cut –d”|” –f3 filename | sort –u
# sort –m foo1 foo2 foo3

Uniq – Locate repeated and non-repeated lines
# sort dept.lst | uniq
# cut –d”|” –f3 emp.lst | sort | uniq –u                                 ( -u selects only lines which is not repeated)
# cut –d”|” –f3 emp.lst | sort | uniq –d                                 ( -d selects one copy of repeated lines)
# cut –d”|” –f3 emp.lst | sort | uniq –c

tr – Translating characters
# tr ‘|/’ ‘~-‘ < emp.lst | head –n 3             – To replace the | with a ~ and the / with a  -.
# head –n 3 emp.lst | tr ‘[a-z]’ ‘[A-Z]’     – Change first three lines from lower to upper.
# tr –d ‘|’ < emp.lst | head –n 3                                – To deleting characters

grep – Searching for a pattern
# grep “director” filename1 filename2
# grep “Rajesh Kumar” filename1
# grep –i ‘rajesh’ filename1                                         To Ignore case
# grep –v ‘rajesh’ filename1 > filename2                              To Select all except lines containing patterns
# grep –n ‘rajesh’ filename1                                       To Display line numbers
# grep –c ‘rajesh’ filename                                          Counting line containing pattern
# grep –l ‘rajesh’ *.lst                                                    -l options display only the name of files containing pattern
# grep –f pattern.lst emp.lst                                       Taking patterns from files

Grep a file, but show several surrounding lines?

For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for th number of lines after the match.
grep -B 3 -A 2 foo README.txt

If you want the same amount of lines before and after you can use -C num.
grep -C 3 foo README.txt
This will show 3 lines before and 3 lines after.

Basic Regular Expression tables

Symbols or Expressions Matches
* Zero or more occurrances of the previous character
g* Nothing or g,gg,ggg, etc
. A Single Character
.* Nothing or any number of character
[pqr] A single character p, q or r
[c1-c2] A Single Character with ASCII range
[1-3] A single digit between 1 and 3
[^pqr] A Single character which is not a p,q or r
[^a-zA-Z] A non-alphabetic character
^pat Pattern pat at the beginning of the line
pat$ Pattern pat at the end of the line
bash$ Bash at the end of the line
^bash$ Bash as the only one word in line
^$ Line containing nothing
+ Matches one or more character of previous character
? Matches zero or one occurrence of the previous character
| Delimiter for multiple pattern
( ) Group pattern

Example:
# grep “[aA]g[ar][ar]wal filename
# grep “[aA]gg*[ar][ar]wal” filename
# grep “j.*Saxena” filename
# grep “^2” filename
# grep “7…$” filename
# grep “^[^2]” filename
# grep –E “[aA]gg?arwal” filename
# grep –E ‘sengupta|dasgupta’ filename
# grep –E ‘(sen|das)gupta’ filename

Editor
Awk  – http://www.thegeekstuff.com/2010/01/awk-introduction-tutorial-7-awk-print-examples/
Sed
vi

# sed – The Stream Editor
# sed ‘3q’ filename == head –n 3                              Quit after line number 3
# sed –n ‘1,2p’ filename                                                               Prints the first 2 lines. Must use –n with p
# sed –n ‘$p’ filename                                                   print last line
# sed –n ‘9,11p 7,9p $p’ filename
# sed –n ‘3,$ip’ filename                                              Don’t print line 3 to the end, display only line 1 and 2

# sed –n ‘/director/p’ filename                                 To print the lines which has pattern in filename
# sed –n ‘/dasgupta/,/saksena/p’ filename
# sed –n ‘1,/dasgupta/p’ filename
# sed –n ‘/[aA]gg*[ar][ar]wal/p’ filename
# sed –n ‘/sa[kx]s*ena/p /Gupta/p’ filename
# sed –n ‘/50…..$/p’ filename

# sed –n ‘director/w  dlsit’ filename
# sed –n ‘director/w dlist /manager/w mlist /executive/w elist’ filename
# sed –n ‘1,500w foo1 501,$w foo2’ filename

# sed ‘1i\
> #include <stdio.h>\
> #include<unistd.h>
>’ foo.c  >> $$                                                                    Include these include on beginning of the program
# sed ‘a\

‘ filename                                                                            # insert after every line this blank line
# sed “/director/d’ filename > filename2              -n option not to be used with d
== # grep –v “director” filename > filename2
# sed –n ‘/director/!p’ filename1 > filename2

# sed ‘s/|/:/’ filename | head -2
# sed ‘s/|/:/g’ filename | head -2
# sed ‘1,3s/|/:/g’ filename
# sed ‘1,5s/director/member /’ filename
# sed ‘s/^/2’ filename
# sed ‘s/$.00/’ filename

Sed tables

Command Description
I,a,c Insert, Appends and Changes text
d Delete lines
10q Quit after reading the first 10 lines
p Print line on standard outputs
3,$p Print lines 3 to the end. –n option is required
$!p Prints all lines except last line. –n option required
/begin/,/end/p Print lines enclosed between begin and end. –n option required
q Quit after reading uo to the address line
 

Vi – Editor                           

IMPORTANT – YOU SHOULD USE DOUBLE QUOTES ONLY WHEN PARAMETER EVALULATION OR command substitution is embedded within command

Write about command “w”

Tagged : / / / / / / / / / / / / / / / /

Perforce backup commands | Perforce backup method

perforce-backup-commands

There are several commands and arguments that allow more complex operations. (A command line flag “-z” tells Perforce to use compre ssion.) The commands are as follows:

p4d -jc [-z] – Take a checkpoint, rotate the journal

p4 admin checkpoint [-z] – Client-side checkpoint/journal

p4d -jj [-z] – Rotate the journal

p4d -jr [-z]filename – Restore the journal file filename

p4d -jd [-z] filename – Checkpoint to filename without incrementing the checkpoint/journal counter

p4d -c command – Lock the database files, and run command

Tagged : / / / / / / / / / / / / / /

How to Execute external commands by using perl?

execute-external-commands-from-perl

There are many ways to execute external commands from Perl. The most commons are:

  • system function
  • exec function
  • backticks (“) operator
  • open function

All of these methods have different behaviour, so you should choose which one to use depending of your particular need. In brief, these are the recommendations:

method use if …
system() you want to execute a command and don’t want to capture its output
exec you don’t want to return to the calling perl script
backticks you want to capture the output of the command
open you want to pipe the command (as input or output) to your script

More detailed explanations of each method follows:

Using system()
system() executes the command specified. It doesn’t capture the output of the command.
system() accepts as argument either a scalar or an array. If the argument is a scalar, system() uses a shell to execute the command (“/bin/sh -c command”); if the argument is an array it executes the command directly, considering the first element of the array as the command name and the remaining array elements as arguments to the command to be executed.
For that reason, it’s highly recommended for efficiency and safety reasons (specially if you’re running a cgi script) that you use an array to pass arguments to system()

Example:      #-- calling 'command' with  arguments    system("command arg1 arg2 arg3");         #-- better way of calling the same command    system("command", "arg1", "arg2",  "arg3");     The return value  is set in $?; this value is the exit status of the command as returned  by the 'wait' call; to get the real exit status of the command you have to  shift right by 8 the value of $? ($? >> 8).     If the value of $? is -1, then the command failed to execute, in that case you may check the value  of $! for the reason of the failure.
Example:      system("command",  "arg1");    if ( $? == -1 )    {      print "command failed: $!\n";    }    else    {      printf "command exited with value %d", $? >> 8;    }

Using exec()
The exec() function executes the command specified and never returns to the calling program, except in the case of failure because the specified command does not exist AND the exec argument is an array.
Like in system(), is recommended to pass the arguments of the functions as an array.

Using backticks (“)
In this case the command to be executed is surrounded by backticks. The command is executed and the output of the command is returned to the calling script.
In scalar context it returns a single (possibly multiline) string, in list context it returns a list of lines or an empty list if the command failed.
The exit status of the executed command is stored in $? (see system() above for details).

Example:      #-- scalar context    $result = `command arg1 arg2`;         #-- the same command in list context    @result = `command arg2 arg2`;     Notice that the  only output captured is STDOUT, to collect messages sent to STDERR you should  redirect STDERR to STDOUT
Example:      #-- capture STDERR as well  as STDOUT    $result = `command 2>&1`;

Using open()
Use open() when you want to:
– capture the data of a command (syntax: open(“command |”))
– feed an external command with data generated from the Perl script (syntax: open(“| command”))

Examples:      #-- list the processes  running on your system    open(PS,"ps -e -o pid,stime,args |") || die "Failed: $!\n";    while ( <PS> )    {      #-- do something here    }         #-- send an email to user@localhost    open(MAIL, "| /bin/mailx -s test user\@localhost ") || die  "mailx failed: $!\n";  print MAIL "This is a test message";
Tagged : / / / / / / / / / / / / / / /

Common unix commands and utilities | unix commands and utilities Guide

unix-commands-and-utilities

To find a program not on this list (and there are hundreds), try the man program with the -k option followed by a keyword, for example,
man -k tape
to find all on-line manual entries that refer to programs that work with tapes.

Terminal control characters for C-shell (csh)

^h, backspace erase previously typed character
^u erase entire line of input so far typed
^d end-of-input for programs reading from terminal
^s suspend writing to terminal (freezes terminal)
^q continue writing to terminal
^z suspend currently running job; restart with bg or fg
^c kill currently running program and allow clean-up before exiting
^\ emergency kill of currently running program with no chance of cleanup

Also see a list of special characters that should not be used in filenames.

Login and authentication

login access computer; start interactive session
logout disconnect terminal session
passwd change local login password; you must set a strong password that is not easily guessed
kinit obtain kerberos ticket for connections to other kerberized computers
kdestroy destroy kerberos tickets (authorizations)

Information

date show date and time
history list of previously executed commands
man show online documentation by program name
info online documentation for GNU programs
w, who who is on the system and what they are doing
whoami who is logged onto this terminal
top show system stats and top CPU using processes
uptime show one line summary of system status

File management

cat combine files
cp copy files
ls list files in a directory and their attributes
mv change file name or directory location
rm remove files
ln create another link (name) to a file
chmod set file permissions
crypt encode/decode a file with a private key
gzip, gunzip compress/decompress a file
find find files that match specific criteria

Display contents of files

cat copy files to display device
more show text file on display terminal with paging control
head show first few lines of a file(s)
tail show last few lines of a file; or reverse line order
vi full-featured screen editor for modifying text files
pico simple screen editor for modifying text files
grep display lines that match a pattern
lpr send file to printer
pr format file with page headers, multiple columns, etc.
diff compare two files and show differences
cmp compare two binary files and report if different
comm compare two files; show common or unique lines
od display binary files as eqivalent octal/hex codes
strings show printable text embedded in binary files
file examine file(s) and guess type: text, data, program, etc.
wc count characters, words, and lines in a file

Directories

cd change to new directory
mkdir create new directory
rmdir remove empty directory (you must remove files first)
mv change name of directory
pwd show current directory

Disks

df summarize free space on disk filesystems
du show disk space used by files or directories

Special character handling for C-shell (See man csh)

* match any characters in a file name
~user shorthand for home directory of user
$name substitute value of variable name
\ turn off special meaning of character that follows
in pairs, quote string with special chars, except !
in pairs, quote string with special chars, except !, $
` in pairs, substitute output from enclosed command

Controlling program execution for C-shell (See man csh)

& run job in background
^c kill job in foreground
^z suspend job in foreground
fg restart suspended job in foreground
bg run suspended job in background
; delimit commands on same line
() group commands on same line
! re-run earlier commands from history list
jobs list current jobs
ps show process information
kill kill background job or previous process
nice run program at lower priority
at run program at a later time
crontab run program at specified intervals
limit see or set resource limits for programs
alias create alias name for program (normally used in .login file)
sh, csh execute command file

Controlling program input/output for C-shell (See man csh)

| pipe output to input
> redirect output to a storage file
< redirect input from a storage file
>> append redirected output to a storage file
tee copy input to both file and next program in pipe
script make file record of all terminal activity

Email and communication

msgs read system bulletin board messages
mailx send/read email; can be run by other programs to send exisiting files via email
uuencode
uudecode
encode/decode a binary file for transmission via email
rn read USENET news groups

Editors and formatting utilities

sed programmable text editor for data streams
vi full-featured editor for character terminals
emacs GNU emacs editor for character terminals
xemacs GNU emacs editor for X Window terminals
pico very simple text editor
fmt fill and break lines to make all same length
fold break long lines to specified length

X Window client programs (output to X terminal or server)

xterm provide login shell window
xauth manipulate authorization files
xload show system load
xman full screen online manual viewer
xemacs GNU emacs editor
gv interface to contol gs to display PostScript or PDF files on screen
xdvi display DVI files on X Window (screen preview)
gnuplot interactive data plotting on screen

TeX typesetting system

tex process TeX files to DVI (device independent) output
latex process LaTeX files to DVI
dvips print DVI files on Postscript laser printer
xdvi display DVI files on X Window (screen preview)
latex2html translate LaTeX files to HTML (for web pages)

Printing (BSD based)

lpr send file to print queue
lpq examine status of files in print queue
lprm remove a file from print queue
enscript convert text files to PostScript format for printing

Interpreted languages and data manipulation utilities

sed programmable text editor for data streams
awk pattern scanning and processing language
perl Practical Extraction and Report Language
sort sort or merge lines in a file(s) by specified fields
tr translate characters
cut cut out columns from a file
paste paste columns into a file
dd copy data between devices; reblock; convert EBCDIC

Graphics and mapping

gnuplot interactive data plotting; outputs to PostScript or X Window
gs “ghostscript” converter displays PostScript files on X Window displays or other devices

Networking/communications

ssh remote login/command execution; encrypted
scp remote non-interactive file copy; encrypted
sftp remote interactive file copy; encrypted
telnet remote network login; plain text password – not recommended
ftp network file transfer program; plain text password – not recommended
host find IP address for given host name, or vice versa
lynx web browser for character based (text-only) terminals
gzip, gunzip compress/decompress a file
tar combine multiple files/dirs into single archive
uuencode
uudecode
encode/decode a binary file for transmission via email

Compilers, interpreters and programming tools

csh command language interpreter (C-shell scripts)
ksh command language interpreter (Korn-shell scripts)
sh command language interpreter (Borne-shell scripts)
f77 Fortran 77 compiler
f2c convert fortran source code to C source code
gcc GNU C compiler
g++ GNU C++ compiler
dbx command-line symbolic debugger for compiled C or Fortran
make recompile programs from modified source
cflow generate C flow graph

Programming libraries (see man library_name)

lapack Fortran 77 routines for numerical linear algebra (supersedes LINPACK and EISPACK)
X routines to interface with X window system (no man page — get the X Toolkit book)
dbm database routines
xdr library routines for external data representation
netcdf routines for machine independent data representation

Tape manipulation and archiving

mt manipulate tape drive and position tape
dd unformatted tape read and write; file conversion
tar archive disk files on tape or disk
ltf read/write ANSI standard label tapes
Tagged : / / / / / / / / / / / / / / / /

A sample Ant build script that builds a WAR file – Guide

ant-build-script-war-file

A sample Ant build script that builds a WAR file

<project name=”MyWebApplication” basedir=”..” default=”install”>

<!– project-specific variables –>
<property name=”jsp.dir.name” value=”myapp” />
<property name=”package.name” value=”${jsp.dir.name}.war” />
<property name=”webapp.dir” value=”/Users/al/tomcat-6.0.16/webapps” />

<property environment=”env” />
<property name=”build.dir” value=”build” />
<property file=”${build.dir}/build.${env.HOSTNAME}” />

<property name=”lib.dir” value=”lib” />
<property name=”pages.dir” value=”pages” />
<property name=”src.dir” value=”src” />
<property name=”src.tests.dir” value=”src-tests” />
<property name=”resources.dir” value=”resources” />
<property name=”dest.dir” value=”target” />

<!– put everything in a temp folder with the right structure during the build –>
<property name=”temp.dir” value=”temp” />
<property name=”temp.dir.web-inf” value=”${temp.dir}/WEB-INF” />
<property name=”temp.dir.lib” value=”${temp.dir.web-inf}/lib” />
<property name=”temp.dir.classes” value=”${temp.dir.web-inf}/classes” />
<property name=”temp.dir.meta-inf” value=”${temp.dir}/META-INF” />

<property name=”package.file” value=”${dest.dir}/${package.name}” />

<path id=”build.class.path”>
<fileset dir=”lib”>
<include name=”**/*.jar” />
</fileset>
</path>

<target name=”clean”>
<delete>
<fileset dir=”${dest.dir}” includes=”**/*”/>
</delete>
<delete dir=”${temp.dir}” />
<delete dir=”${temp.dir.classes}” />
<delete dir=”${temp.dir.meta-inf}” />
<delete dir=”${temp.dir.web-inf}” />
</target>

<target name=”prepare” depends=”clean”>
<mkdir dir=”${dest.dir}” />
<mkdir dir=”${temp.dir}” />
<mkdir dir=”${temp.dir.lib}” />
<mkdir dir=”${temp.dir.meta-inf}” />
<mkdir dir=”${temp.dir.web-inf}” />
<mkdir dir=”${temp.dir.classes}” />
</target>

<!– COMPILE –>
<target name=”compile” depends=”prepare”>
<echo>=== COMPILE ===</echo>
<echo>Compiling ${src.dir} files …</echo>
<javac debug=”on” srcdir=”${src.dir}” destdir=”${temp.dir.classes}” includes=”**/*”>
<classpath refid=”build.class.path” />
</javac>

<!– compile files on the src-tests path –>
<echo>Compiling ${src.tests.dir} files …</echo>
<javac debug=”on” srcdir=”${src.tests.dir}” destdir=”${temp.dir.classes}” includes=”com/**”>
<classpath refid=”build.class.path” />
</javac>
</target>

<!– PACKAGE –>
<target name=”package” depends=”compile”>
<echo>=== PACKAGE ===</echo>

<!– copy the config files –>
<copy file=”${resources.dir}/MANIFEST.MF” tofile=”${temp.dir.meta-inf}/MANIFEST.MF” overwrite=”true” />
<copy file=”${resources.dir}/web.xml” tofile=”${temp.dir.web-inf}/web.xml” overwrite=”true” />
<copy file=”${resources.dir}/managed-beans.xml” tofile=”${temp.dir.web-inf}/managed-beans.xml” overwrite=”true” />
<copy file=”${resources.dir}/navigation-rules.xml” tofile=”${temp.dir.web-inf}/navigation-rules.xml” overwrite=”true” />

<copy todir=”${temp.dir.classes}”>
<fileset dir=”${src.dir}”>
<include name=”**/*.xml”/>
<include name=”**/*.xsl”/>
</fileset>
</copy>

<!– with all resources in place, create the war file –>
<war destfile=”${package.file}” webxml=”${temp.dir.web-inf}/web.xml” basedir=”${temp.dir}”>
<fileset dir=”${pages.dir}”/>
<lib dir=”${lib.dir}” />
<classes dir=”${temp.dir.classes}” />
</war>
</target>

<!– JUST DEPLOY JSP’s –>
<target name=”jsps”>
<echo>=== DEPLOY JSP’S ===</echo>
<!– i’m trying to be explicit about what i put out there –>
<copy todir=”${webapp.dir}/${jsp.dir.name}”>
<fileset dir=”${pages.dir}”>
<include name=”**/*.jsp”/>
<include name=”**/*.html”/>
<include name=”**/*.css”/>
<include name=”**/*.gif”/>
<include name=”**/*.jpg”/>
<include name=”**/*.png”/>
<include name=”**/*.js”/>
</fileset>
</copy>
</target>

<!– INSTALL –>
<target name=”install” depends=”package”>
<echo>=== INSTALL ===</echo>
<copy file=”${package.file}” tofile=”${webapp.dir}/${package.name}” overwrite=”true” />
</target>

</project>

Tagged : / / / / / / / / / / / / / / / / /

Windows XP/2000 Commands & Tools | Windows XP Command-line Reference

windows-xp-2000-commands-tools

Here’s the ultimate Windows XP/2000 command list that will make any Linux user feel at home at the command prompt. A lot of these commands are intended for administrating a network, but they are great for savvy home users as well.  We even listed which OS you need for these commands.

Many thanks to the digg users who ‘dugg’ our site and care to leave comments of helpful commands that we have left out!

  • at (windows XP/2000)
    Scheduling utility.
  • bootcfg (XP only)
    This utility allows you to set up your boot options, such as your default OS and other loading options.
  • cacls (XP, 2000, & NT4.0)
    Changes the ACLs (security Settings) of files and folders. Very similar to chmod in Linux. 
  • comp (XP & 2000)
    This utility is very similar to diff in Linux.  Use the /? switch to get examples of command usage.
  • contig (works with NT4.0 and newer)
    A great defrag utility for NTFS partitions.
  • control (XP only) – unpublished!
    Allows you to launch control panel applets from the command line. 
    control userpasswords2, for example will launch a helpful local user admin utility.
  • defrag (XP only – NT4.0 and Win2k use contig)
    Yes, XP comes with a command line disk defrag utility. If you are running Win2k or NT4.0 there is still hope. Contig is a free defrag program that I describe on the defrag page.
  • diskpart (XP only)
    Use this command to manage your disk partitions.  This is the text version for the GUI Disk Manager.
  • driverquery (XP only)
    Produces a list of drivers, their properties, and their versions. Great for computer documentation.
  • eudcedit (XP only) – unpublished!
    Private Character editor.  Yes with this program built into Windows XP you can create your own font!
  • fsutil (XP only) – unpublished!
    This is a utility with a lot of capability.  Come back soon for great examples.
  • getmac (XP & 2000)
    This command gets the Media Access Control (MAC) address of your network cards.
  • gpresult (XP & 2000)
    This generates a summary of the user settings and computer group policy settings.
  • gpupdate (XP only)
    Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain.
  • ipconfig (XP, 2000 & NT4.0)
    This handy tool displays IP settings of the current computer and much more.
  • MMC (XP, 2000 & NT4.0) – Microsoft Management Console
    This is the master tool for Windows, it is the main interface in which all other tools use starting primarily in Windows 2000 and newer systems.
  • more
    Utility used to display text output one screen at a time. Ex. more c:\windows\win.ini
  • msconfig (XP only)
    The ultimate tool to change the services and utilities that start when your Windows machine boots up. You can also copy the executable from XP and use it in Win2k.
  • msinfo32 (XP &smp; 2000)
    An awesome diagnostic tool. With it you can get a list of running processes, including the residing path of the executable (great for manually removing malware) and get detailed information about hardware and system diagnostics.
  • narrator (XP only)
    Turns on the system narrator (can also be found in accessibility options in control panel).  Will will allow your computer to dictate text to you.
  • netsh (XP & 2000)
    A network configuration tool console.  At the ‘netsh>’ prompt, use the ‘?’ to list the available commands and type “exit” to get back to a command prompt.
  • nslookup (all)
    A DNS name resolution tool.
  • openfiles (XP Only)
    Allows an administrator to display or disconnect open files in XP professional. Type “openfiles /?” for a list of possible parameters.
  • Pathping (XP & 2000)
    A cross between the ping and traceroute utilities. Who needs Neotrace when you can use this? Type “pathping <ip address>” and watch it go.
  • recover (XP & 2000)
    This command can recover readable information from a damaged disk and is very easy to use.
  • reg (XP & 2000)
    A console registry tool, great for scripting Registry edits.
  • sc (XP & 2000)
    A command line utility called the Service Controller.  A power tool to make service changes via a logon/logoff or startup/shutdown script.
  • schtasks (XP only)
    A newer version of the AT command.  This allows an administrator to schedule and manage scheduled tasks on a local and remote machines.
  • secedit (XP & 2000)
    Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain.  Example to update the machine policy: secedit /refreshpolicy machine_policy /enforce
    To view help on this, just type secedit.
    NOTE: In Windows XP SP1 and news, this command is superceded by: gpupdate /force
  • sfc (XP & 2000)
    The system file checker scans important system files and replaces the ones you (or your applications) hacked beyond repair with the real, official Microsoft versions.
  • shutdown (XP & 2000)
    With this tool, You can shut down or restart your own computer, or an administrator can shut down or restart a remote computer.
  • sigverif (XP only)
    Microsoft has created driver signatures. A signed driver is Microsoft tested and approved. With the sigverif tool you can have all driver files analyzed to verify that they are digitally signed. Just type ‘sigverif’ at the command prompt.
  • systeminfo (XP only)
    Basic system configuration information, such as the system type, the processor type, time zone, virtual memory settings, system uptime, and much more.  This program is great for creating an inventory of computers on your network.
  • sysedit (XP/2000)
    System Configuration File Editor.  An old tool that was very handy for the Windows 9X days.  msconfig is what you want to use now.
  • tasklist (XP pro only)
    Tasklist is the command console equivalent to the task manager in windows. It is a must have when fighting scumware and viruses. Try the command:
    tasklist /svc
    to view the memory resources your services take up.
  • taskkill (XP only)
    Taskkill contains the rest of the task manager functionality.  It allows you to kill those unneeded or locked up applications.
  • tree (XP & 2000)
    An amazing experience everyone should try!  This command will provide a ‘family tree’ style display of the drive/folder you specify.
  • WMIC (XP & 2000)
    Windows Management Instrumentation Command tool.  This allows you to pull an amazing amount of low-level system information from a command line scripting interface.
Tagged : / / / / / / / / / / / / / / / / /

VI/VIM editor Commands | VI/VIM editor commands reference | Cheat Sheet

vi-vim-editor-commands

  • what will happen ?

“man ls |col -b > ” will give the text file same as man ls.

  • what is VI-editor ?

While in vi you can run AIX commands without exiting the editing session. The! creates a
shell to execute the command that follows.
1. :!ls will create a shell
2. All files in the current directory are listed. Press return to exit the shell and return to the
vi session or…
3. While still in command mode, issue the :r snacks command
4. The contents of snacks, in this case, are read into the vi file. By default, it will appear
after the current line.
If you need to run a series of commands without returning to vi after the first command is
executed, enter :sh. When you have run all the commands, press to exit the shell
and return to vi.

  • VI Options:-

vi has many modes of operation. Some of these will affect the way text is presented, while
others will make editing easier for novice users.
:set all display all settings
:set display settings different than the default
:set ai sets autoindent on
:set noai turns autoindent mode off
:set nu enables line numbers
:set nonu turns line numbers off
:set list displays non-printable characters
:set nolist hides non-printable characters
:set showmode shows the current mode of operation
:set noshowmode hides mode of operation
:set ts=4 sets tabs to 4-character jumps
:set ic ignores case sensitivity
:set noic case sensitive

  • Search

/word     Search “word” from top to bottom
?word     Search “word” from bottom to top
/jo[ha]n     Search “john” or “joan”
/\< the     Search “the”, “theatre” or “then”
/the\>     Search “the” or “breathe”
/\     Search “the”
/\     Search all words of 4 letters
/\/     Search “fred” but not “alfred” or “frederick”
/fred\|joe     Search “fred” or “joe”
/\     Search exactly 4 digits
/^\n\{3}     Find 3 empty lines
:bufdo /searchstr/     Search in all open files

  • Replace

:%s/old/new/g     Replace all occurences of “old” by “new” in file
:%s/old/new/gw     Replace all occurences with confirmation
:2,35s/old/new/g     Replace all occurences between lines 2 and 35
:5,$s/old/new/g     Replace all occurences from line 5 to EOF
:%s/^/hello/g     Replace the begining of each line by “hello”
:%s/$/Harry/g     Replace the end of each line by “Harry”
:%s/onward/forward/gi     Replace “onward” by “forward” , case unsensitive
:%s/ *$//g     Delete all white spaces
:g/string/d     Delete all lines containing “string”
:v/string/d     Delete all lines containing which didn’t contain “string”
:s/Bill/Steve/     Replace the first occurence of “Bill” by “Steve” in current line
:s/Bill/Steve/g     Replace “Bill” by “Steve” in current line
:%s/Bill/Steve/g     Replace “Bill” by “Steve” in all the file
:%s/\r//g     Delete DOS carriage returns (^M)
:%s/\r/\r/g     Transform DOS carriage returns in returns
:%s#]\+>##g     Delete HTML tags but keeps text
:%s/^\(.*\)\n\1$/\1/     Delete lines which appears twice
Ctrl+a     Increment number under the cursor
Ctrl+x     Decrement number under cursor
ggVGg?     Change text to Rot13

 

  • Case

Vu     Lowercase line
VU     Uppercase line
g~~     Invert case
vEU     Switch word to uppercase
vE~     Modify word case
ggguG     Set all text to lowercase
:set ignorecase     Ignore case in searches
:set smartcase     Ignore case in searches excepted if an uppercase letter is used
:%s/\<./\u&/g     Sets first letter of each word to uppercase
:%s/\<./\l&/g     Sets first letter of each word to lowercase
:%s/.*/\u&     Sets first letter of each line to uppercase
:%s/.*/\l&     Sets first letter of each line to lowercase

  • Read/Write files

:1,10 w outfile     Saves lines 1 to 10 in outfile
:1,10 w >> outfile     Appends lines 1 to 10 to outfile
:r infile     Insert the content of infile
:23r infile     Insert the content of infile under line 23

  • File explorer

:e .     Open integrated file explorer
:Sex     Split window and open integrated file explorer
:browse e     Graphical file explorer
:ls     List buffers
:cd ..     Move to parent directory
:args     List files
:args *.php     Open file list
:grep expression *.php     Returns a list of .php files contening expression
gf     Open file name under cursor

  • Interact with Unix

:!pwd     Execute the “pwd” unix command, then returns to Vi
!!pwd     Execute the “pwd” unix command and insert output in file
:sh     Temporary returns to Unix
$exit     Retourns to Vi

  • Alignment

:%!fmt     Align all lines
!}fmt     Align all lines at the current position
5!!fmt     Align the next 5 lines

  • Tabs

:tabnew     Creates a new tab
gt     Show next tab
:tabfirst     Show first tab
:tablast     Show last tab
:tabm n(position)     Rearrange tabs
:tabdo %s/foo/bar/g     Execute a command in all tabs
:tab ball     Puts all open files in tabs

  • Window spliting

:e filename     Edit filename in current window
:split filename     Split the window and open filename
ctrl-w up arrow     Puts cursor in top window
ctrl-w ctrl-w     Puts cursor in next window
ctrl-w_     Maximise current window
ctrl-w=     Gives the same size to all windows
10 ctrl-w+     Add 10 lines to current window
:vsplit file     Split window vertically
:sview file     Same as :split in readonly mode
:hide     Close current window
:only     Close all windows, excepted current
:b 2     Open #2 in this window

  • Auto-completion

Ctrl+n Ctrl+p (in insert mode)     Complete word
Ctrl+x Ctrl+l     Complete line
:set dictionary=dict     Define dict as a dictionnary
Ctrl+x Ctrl+k     Complete with dictionnary

  • Marks

mk     Marks current position as k
‘k     Moves cursor to mark k
d’k     Delete all until mark k
Abbreviations
:ab pr printf(“This is a Demo Ver \n”);    Define pr as abbreviation of printf(“This is a Demo Ver \n”);

  • Text indent

:set autoindent     Turn on auto-indent
:set smartindent     Turn on intelligent auto-indent
:set shiftwidth=4     Defines 4 spaces as indent size
ctrl-t, ctrl-d     Indent/un-indent in insert mode
>>     Indent
<<     Un-indent

  • Syntax highlighting

:syntax on     Turn on syntax highlighting
:syntax off     Turn off syntax highlighting
:set syntax=perl     Force syntax highlighting

  • How to Exit

:q[uit]     Quit Vim. This fails when changes have been made.
:q[uit]!     Quit without writing.
:cq[uit]     Quit always, without writing.
:wq     Write the current file and exit.
:wq!     Write the current file and exit always.
:wq {file}     Write to {file}. Exit if not editing the last
:wq! {file}     Write to {file} and exit always.
:[range]wq[!]     [file] Same as above, but only write the lines in [range].
ZZ     Write current file, if modified, and exit.
ZQ     Quit current file and exit (same as “:q!”).

  • Editing a File

:e[dit]     Edit the current file. This is useful to re-edit the current file, when it has been changed outside                 of Vim.
:e[dit]!     Edit the current file always. Discard any changes to the current buffer. This is useful if you want                 to start all over again.
:e[dit] {file}     Edit {file}.
:e[dit]! {file}     Edit {file} always. Discard any changes to the current buffer.
gf     Edit the file whose name is under or after the cursor. Mnemonic: “goto file”.

  • Inserting Text

a     Append text after the cursor [count] times.
A     Append text at the end of the line [count] times.
i     Insert text before the cursor [count] times.
I     Insert text before the first non-blank in the line [count] times.
gI     Insert text in column 1 [count] times.
o     Begin a new line below the cursor and insert text, repeat [count] times.
O     Begin a new line above the cursor and insert text, repeat [count] times.

  • Inserting a file

:r[ead] [name]     Insert the file [name] below the cursor.
:r[ead] !{cmd}     Execute {cmd} and insert its standard output below the cursor.
 

Tagged : / / / / / / / / / / / / / / / / / / / / / / / / / / / / /