Showing posts with label Commands. Show all posts
Showing posts with label Commands. Show all posts

Tuesday, June 12, 2012

Is it possible to run a .bat file in Linux?

No

You will have to change the file to the Linux format, .sh file and then execute it.


Example:

I have a TESTTool folder which contains 2 folders:
1. bin folder with a Tool.jar file &
2. lib folder with Communication.jar file in it


start.bat file looks like this:

cd bin
java -classpath ..\lib\*;Tool.jar testtool.UIFrame


..\lib\* command selects all files in the folder lib.


The folder was added in Ubuntu PC and then provided permission to it.
And the file start.bat was Saved as start.sh file.

But while executing the application, it throws error :

Could not find the Communication class..

Issue 1:
Linux will not select the files in the folder using the command,
..\lib\*;

You have to specify the jar file in the lib folder.

Issue 2
After saving a .bat file to .sh file,
You have to convert the .sh file into linux format using the command
dos2unix start.sh


The start.sh file will look like:

cd bin
java -classpath ../lib/Communication.jar:Tool.jar testtool.UIFrame

Monday, May 2, 2011

Change file ownership in Linux

How to Change the Ownership of a File in Linux

I listed the file using the command ls -l in terminal.
The command displayed the ownership of the file as my.
-rw-r--r-- 1 my my 420 2011-05-02 11:03 IP.dat


I need to convert the ownership of IP.dat file to root

Type the command,
chown root:root IP.dat
in terminal.

The command has changed the ownership of the file to root
-rw-r--r-- 1 root root 420 2011-05-02 11:03 IP.dat

Thursday, April 7, 2011

Linux command to find the number of processes running in a PC.

Command to find the number of processes running in a PC

For eg:-, if I need to find the number of postgres processes running in my pc, just run the command,
ps -C postgres | wc -l

Friday, March 11, 2011

Copy file permissions from one file to another

I need to copy the file permission of FirstFile.jar to SecondFile.jar.

You may know how to change file permissions using chmod but, if you already have a file with the permissions you want to assign to some other files, you can use --reference option in chmod


chmod --reference
As an example, if you have this:

-rwxrwxrwx 1 root root 0 Dec 20 15:35 FirstFile.jar
-rwx------ 1 root root 0 Dec 20 15:35 SecondFile.jar
And you run:

chmod --reference FirstFile.jar SecondFile.jar
You should then have this:

-rwxrwxrwx 1 root root 0 Dec 20 15:35 FirstFile.jar
-rwxrwxrwx 1 root root 0 Dec 20 15:35 SecondFile.jar
Just be sure, you are the owner of the files, you that you have permission to change them.

Tuesday, January 4, 2011

Command to find out the ports opened for an IP address

Enter the command in terminal
nmap -v x.x.x.x

This will display the ports opened for that IP address.

Tuesday, November 16, 2010

Useful Linux Commands

• List files, starting with 'V_20100810' and sort results by most recent
ls -lt V_20100810*

• File monitoring(tail displays the lines and then monitors the file)
tail -f V_20100810_DataAccq.log

• Linux version
cat /etc/*-release

• List files with permission details
ls –l

• Remove a folder with its contents
rm –r –f foldername

• Remove all files in a folder
rm -r -f *

• Shutdown PC
shutdown -h now

• Change the user and/or group ownership of each file-chown
chown newowner filename

chown root:root /backup
setup user and group ownership to root user only for /backup directory

chown root:ftp /home/data/file.txt
Set user user ownership to root user and allow any member of ftp group to access file.txt (provided that they have sufficient read/write rights).

• Change file access permissions such as read, write etc. - chmod
chmod [-r] permissions filenames
• r - Change the permission on files that are in the subdirectories of
the directory that you are currently in.
permission - Specifies the rights that are being granted. Below is the
different rights that you can grant in an alpha numeric format.
filenames - File or directory that you are associating the rights with
Permissions
• u - User who owns the file.
• g - Group that owns the file.
• o - Other.
• a - All.
• r - Read the file.
• w - Write or edit the file.
• x - Execute or run the file as a program.


Numeric Permissions:

CHMOD can also to attributed by using Numeric Permissions:

• 400 read by owner
• 040 read by group
• 004 read by anybody (other)
• 200 write by owner
• 020 write by group
• 002 write by anybody
• 100 execute by owner
• 010 execute by group
• 001 execute by anybody