Skip to main content

Posts

Linux and Maven Commands

Maven mvn -Dmaven.test.skip=true -e clean install mvn clean install mvn clean install -Dmaven.test.skip=true Linux: telnet mq.dev.sum.org  9012 telnet <machine_IP> <port> Sudo su Su - sudo -u dev2adm  -i ps -ef|grep jboss Find a folder Just find directories and skip file names pass the  -type d  option as follows: find   / - type d -name "apt" - ls locate httpdocs Delete latest 3 files: rm -f $(ls -1t ./ | head -3)   working fine ls -d -1tr /path/to/folder/* | head -n -10 | xargs -d '\n' rm -f rm -f $(ls -1t ./ | tail -n +4) netstat -ln | grep '80 ' | grep 'LISTEN' netstat -atnp|grep LISTEN  netstat -ln | grep '99 ' | grep 'LISTEN'  netstat -ln | grep '16'  scp -pr Services-0.0.2-SNAPSHOT.war sbiswas@172.1.8.141:/home/sbiswas tail -f /tmp/Liferay-JBoss.out |grep 'PAGENAME\|tabName' grep 'PAGENAME\|tabName'  for multiple se...
Recent posts

Delete 10 newest files in Linux

Delete 10 newest files in Linux The code you'd want to include in your script is rm -f $(ls -1t /path/to/your/logs/ | tail -n +11) The -1 (numeric one) option prints each file on a single line, to be safe. The -f option to  rm  tells it to ignore non-existent files for when  ls  returns nothing. Or use the below command ls -d -1tr /path/to/folder/* | head -n -10 | xargs -d '\n' rm -f Delete latest 3 files: rm -f $(ls -1t ./ | head -3)    Find a folder Just find directories and skip file names pass the  -type d  option as follows: find   / - type d -name "apt" - ls locate httpdocs Gives the time stamp date +%Y%m%d -s "20081128" date +%T -s "11:18:00" Stat file.txt newest=$(find subdir -newer timestamp -printf "%A%p\n" |                 sort -n |          ...

SED COMMAND TO DELETE LINES IN FILE

Sed Command to Delete Lines : Sed command can be used to delete or remove specific lines which matches a given pattern or in a particular position in a file. Here we will see how to delete lines using sed command with various examples. The following file contains a sample data which is used as input file in all the examples: > cat file linux unix fedora debian ubuntu SED COMMAND TO DELETE LINES - BASED ON POSITION IN FILE In the following examples, the sed command removes the lines in file that are in a particular position in a file. 1.  Delete first line or header line The d option in sed command is used to delete a line. The syntax for deleting a line is: > sed 'Nd' file Here N indicates Nth line in a file. In the following example, the sed command removes the first line in a file. > sed '1d' file unix fedora debian ubuntu 2.  Delete last line or footer line or trailer line The following sed comm...

Command used in day to day activity

Command to find the used ports in server netstat -ln | grep '80 ' | grep 'LISTEN' netstat -atnp|grep LISTEN  netstat -ln | grep '99 ' | grep 'LISTEN'  netstat -ln | grep '16' telnet <machine_IP> <port> Command  for copying files to server  scp -pr RMVServices-0.0.2-SNAPSHOT.war shib@100.1.127.11:/home/shib Command for multiple search   tail -f /tmp/Liferay-JBoss.out |grep 'PAGENAME\|tabName' grep 'PAGENAME\|tabName'  for multiple search Command to set line no in VI Editor :set nu   for line no :/ERROR   for ERROR search in VI grep -r devapp214 ./|grep tst2 Command to shutdown jboss  ./shutdown.sh -s 172.23.2.5:7109 ./shutdown.sh -s 172.23.2.25:1399 Command to search files find ./ -name jboss-admin.sh Command to see difference in  files sdiff  ./pdf.css  /opt/dadm/liferay-portal-6.0-ee-sp2/jboss-.1.0/serv...

Hiding a file or directory under Linux

Hiding a file or directory under Linux To hide a file or directory in Linux, just give it a name preceded by a full stop (.). For example: . bash_history . bash_profile . ssh    Hide UNIX file structure   1. Open a terminal and execut "ls -1 / | sudo tee /.hidden" 2. Do "sudo chmod a+r .hidden" 3. If you want all standard files hidden, skip to 5. Otherwise. Open the file with "sudo gedit /.hidden". 4. Remove every directory you don't want to hide from the file. Here's how mine looks like, as an example: bin boot opt usr etc sys tmp srv proc root sbin lib lost+found mnt initrd dev debootstrap var cdrom initrd.img initrd.img.old vmlinuz vmlinuz.old home media 5. Now, let's create some entries that are easier for new users: select "home" and create a link to link to it (for example, by dragging it and holding <ctrl>+<shift>. Your mouse cursor shou...

Touch & More

Touch touch [-acm] [-f agefile] [-r agefile] [[-t] time] file ... touch [-acm] time file ... DESCRIPTION The touch command changes certain dates for each file argument. By default, touch sets both the date of last file modification and the date of last file access to the current time. This is useful for maintaining correct release times for software and is particularly useful in conjunction with the MKS Make software development facility. Options -a     sets only the access time. -c     does not create any files that do not already exist. Normally, touch creates such files. -m     sets only the modification time. If you do not specify -a or -m, touch behaves as though you specified both. To tell touch to use a time other than the current, use one of the following options: -f agefile    is an obsolete version of the POSIX-compliant -r option. -r agefile   ...

Beginners UNIX Interview Questions Answers

1. Write command to list all the links from a directory? In this UNIX command interview questions interviewer is generally checking whether user knows basic use of "ls" "grep" and regular expression etc You can write command like: ls -lrt | grep "^l" 2. Create a read-only file in your home directory? This is a simple UNIX command interview questions where you need to create a file and change its parameter to read-only by using chmod command you can also change your umask to create read only file. touch file chmod 400 file 3. How will you find which operating system your system is running on in UNIX? By using command "uname -a" in UNIX 4. How will you run a process in background? How will you bring that into foreground and how will you kill that process? For running a process in background use "&" in command line. For bringing it back in foreground use command "fg jobid" and for getting j...