need to find the path for my file (cygwin in Window7) - unix

My apology for the "newbie trouble" that I created for myself & apology for my poor command of computer lingo
I am running a Windows 7 laptop and have a big text file (~4Gb) that I need to find certain string.
Most programs in Windows 7 cannot handle the task (file too big to open in any program in the Microsoft suite), so I downloaded cygwin and tried to grep the specific string.
The problem is
(a) the 4 Gb file is stored in the desktop of my non-admin account.
(b) I assume cygwin runs in the admin account (although I use the desktop cygwin icon to launch the environment). The reason being that under cygwin, I see the handle A#Admin-THINK (running it on a Lenovo Thinkpad laptop)
grep the file of interest results in "No such file or directory"
I tried to find the path of the file (readlink, realpath) but guess the commands were not applicable here?
Also tried /home/A/file or /home/A/desktop/file but it is clear that my random guess fails.
From windows, the file should be in
C:/Users/non_admin/desktop/folder/file
What would be the right path of the file to grep the string using cygwin ?

You can use /cygdrive to access the Windows filesystem. In your case, try
grep foo /cygdrive/c/Users/non_admin/Desktop/folder/file

From windows, you can get the correct file path from the context menu item Copy as path into the copy/paste buffer.
In Cygwin mintty, use
FilePath=<paste>
where <paste> means to use paste from mintty's context menu to make a variable with the value of that path.
Then use
grep <string> $(cygpath -u "$FilePath")
to search the file. The "'s are in case the file name contains spaces.
HTH

Related

Partitioned pcap file

I received a network traffic capture that is partitioned is several hundred of small .pcap files with the following format:
name.pcap#
where # is a numeration from 1 to 630.
Something like this:
name.pcap1,name.pcap2,name.pcap3,...,name.pcap630
I know that all of them are from one continue capture but it seems that was partitioned.
I don't have a lot experience working with wireshark, and this type of files are new for me. I don't know how to read them as one file.
I was wondering what can I do to resemble all of them in just one file?
Many thanks in advance,
I was wondering what can I do to resemble all of them in just one file?
At least with the current version of Wireshark, if you:
start Wireshark without opening a file - just directly start the application;
select all 630 of the files in Windows Explorer/File Explorer (Windows), the Finder (macOS), or whatever file manager you are using in the GUI (other UN*Xes - Linux, *BSD, Solaris, AIX, etc.);
drag them into Wireshark;
Wireshark should read all the files and combine them into a single file, showing you all the packets.
I tested this on macOS; I have not tested it on Windows or, for example, Ubuntu, but I suspect it would work.
Note that you must select all the files and drag them all in one operation; if you try to drag them one at a time, they won't be combined, Wireshark will just close the currently open one and open the file that you're dragging and dropping.
Alternatively, Wireshark includes mergecap, which is a tool that "merges two or more capture files into one".
It is a command-line tool, so you will have to use it on the command line (UN*X - Linux, macOS, *BSD, Solaris, AIX, etc. - or Windows).
The command would be something such as
mergecap name.pcap* -w merged.pcap
(on UN*Xs) or
mergecap.exe name.pcap* -w merged.pcap
if you were to run it while your command-line shell is in the directory (folder) in which the files are stored. This command will put a new file, named merged.pcap, in that directory.
You will have to make sure that the directory containing mergecap is in your command-line shell's search path, or will have to type the full pathname rather than just mergecap. (The .exe may not be necessary on Windows with some command-line shells, but it doesn't hurt, and may be necessary with other command-line shells.)
On most UN*Xes, mergecap will probably be in /usr/local/bin or /usr/bin, both of which are in the command-line shell search path by default.
On macOS, mergecap will probably be in /Applications/Wireshark.app/Contents/MacOS/; however, if, when you installed Wireshark, you chose to install the Wireshark command-line tools, it will also be in /usr/local/bin, which is, again, in the command-line shell search path by default.
On Windows, mergecap will probably be in C:\Windows\Program Files\Wireshark. That is probably not in the command-line shell search path by default. If you don't put it in your command-line shell search path, you will have to run a command such as
`"C:\Windows\Program Files\Wireshark\mergecap.exe" name.pcap* -w merged.pcap
Adding it to the command-line shell search path is a painful process, so it's probably easier just to use the full path.
You must include the quote characters (because there's a space in "Program Files").

Unix command line on PC using Ubuntu

I am new to these forums and to using Ubuntu and linux and UNIX. I really need some help here. I hope I haven't shot myself in the foot already. I have been trying to complete a UNIX carpentry lesson on the internet for an assignment. I am learning the basics about UNIX. I am not using a Mac, I am using a PC that I did not configure in any way (maybe that's my problem). I am using windows 10 on a lenovo and trying to the command prompt on Ubuntu to find my desktop where a file called "data-shell" is located. The problem: IT IS NOT FINDING THE DESKTOP. Upon further inspection, I have been looking through the location of my desktop and "data-shell" file and found it in the Users location under a number 12094, which I am assuming is the serial number for the computer. I have NEVER fiddled with the software at all with this computer as it cost me a lot of money, but I really do not want to be stopped in the tracks already. I have the following images numbered in the order that I discovered everything; they are posted here. I would really appreciate the help. P.S.: Since I am using a PC and not mac, I thought I had to use another command line like BASH or the terminal on my PCor doI just use Ubuntu? The UNIX shell is supposed to start with a $, right? Please correct me if I a wrong and thank you for your help
.
linux commands on windows can be ran via cmder or git bash (what i had used in past)
and in linux the desktop is at the path
/home/< username>/Desktop
whereas in windows its
C:\Users<username>\Desktop
both windows (DOS) and ubuntu/mac(linux) environment are entirely different you can directly run commands of one on the other environment, you do need to "setup" that env first if the command is not native to that.
Now, since its assignments that you are doing and all you need is bare-min linux env
you can give https://repl.it/ a try and create a new project in bash
Also, when you install Ubuntu on windows you dont get acces to windows like path, like "C:...", in ubuntu c:\ of windows is mounted to some other path in ubuntu
search on google how to access windows desktop from ubuntu shell after installing ubuntu inside of windows
When using Windows Subsystem for Linux (WSL), your C drive is located under /mnt/c.
Judging from the screenshot, you are user 12094, so you can either accept this, or you need to actually configure your machine. Also if you look in the screenshot you provided, there is a /home folder which I am betting is actually pointing to /mnt/c/, and your home folder will be under /home/12094, which is also the same as what is stored in $HOME.
To find the location of a file called data-shell, you can run the following linux command while in your home folder:
find $HOME -type f -name 'data-shell'
This command recursively searches for files in your home directory, with the name data-shell

Can't find a way to get graphic tablet drivers working on mint

So i was trying to install the XP Pen Driver for my Deco 01 v2 graphics tablet on my Linux Mint 19.2 Tina when i came to encounter the following error:
./Pentablet_Driver: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.10' not found (required by ./Pentablet_Driver)
I went on to install qt 5.10, still the same error. Others suggested to just change the path wth sudo gedit /etc/ld.so.conf.d/randomLibs.conf which didn't change a thing.
Link to drivers:
https://www.xp-pen.com/download-440.html
The manufacturer has a page describing how to set up their software on Linux with pictures. However, when following them, you end up with a folder name somewhere along the line that has spaces in it, which causes issues.
So a modified set of instructions might look like this:
Connect your XP-Pen product to the computer.
Download the Linux Beta driver from XP-Pen official website.
When the download is complete, extract the compressed folder.
Rename the extracted folder to something without spaces.
Inside the renamed folder is another compressed folder which should be extracted.
Inside the final extracted folder, ensure "Pentablet_Driver.sh" has execution permissions by right clicking on it and going to "Properties->Permissions" and verifying that "Allow executing file as program" is checked.
Open the terminal. (CTRL+ALT+T)
Type "sudo ", then drag Pentablet_Driver.sh from the file browser onto the terminal.
Type the password to complete.
Make sure that you write exactly
sudo ./Pentablet_Driver.sh
instead
sudo ./Pentablet_Driver
I had the same error until I noticed that I forgot to add .sh at the end.

Why am i able to run unix commands on my PC?

How am i able to execute UNIX commands on my PC Command prompt? Note i do not have cygwin installed, although i was going to before i discovered this.
This is a development machine so i have a lot installed on it like ruby, python, git, github, node and so on.
What does this mean? can i use this without cygwin?
Here is a list of programs installed on my PC program list
How am I able to execute UNIX commands on my PC Command prompt?
You can use the where command in a cmd shell to find out the exact location of your Unix commands, for example:
where ls
This assumes, of course, that ls is located somewhere in your current PATH.
The location returned will show you in which directory your Unix commands are installed and may be enough for you to determine how they were installed.
The where command is roughly equivalent to the Unix which command.
By default, the search is done in the current directory and in the
PATH.
Syntax
WHERE [/r Dir] [/q] [/f] [/t] Pattern ...
WHERE [/q] [/f] [/t] [$ENV:Pattern
Source where
Further Reading
An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
where - Locate and display files in a directory tree.
Running Unix commands in windows can be done by having a tool like Cygwin which has those commands.
You can also get many of those commands compiled for windows and then run them using the command with the full path or only the command if the executable is in a path known by adding the paths to the executable files in Windows by :
1) Running in the terminal: PATH %PATH%;C:\<new_path>
2) Creating command aliases like: doskey np=C:\<new_path>\new_command.exe $*. $* is used to be able to transmit parameters

Console Window Host, always use quotes?

Console Window Host, or conhost.exe allows you to drag a file or folder into a cmd.exe window, instead of typing the path.
If the path contains any spaces then it is wrapped in double quotes, eg
"C:\Program Files"
Problems
Ampersand
If you happen to have a path with & dragging it will fail
cd C:\foo&bar
The system cannot find the path specified.
'bar' is not recognized as an internal or external command, operable program
or batch file.
Bash
If you happen to be using Bash on Windows then any path without a space will
fail.
$ cd C:\Windows\System32
sh: cd: C:WindowsSystem32: No such file or directory
Is there a way to make conhost always apply the quotes to dragged files?
One alternative is to use Tab to complete the path.
I had to edit my ~/.inputrc to add this.
"\t": complete-filename
source: gnu.org/software/bash/manual/bashref
Use mintty
It is the default terminal in Cygwin.
It is also available for MinGW.
It uses Linux like paths when dragging
Adds quotes when necessary.
Note
mintty will not have colors when running native Windows shell apps.
superuser.com/questions/184186
Use Console
It is available for MinGW
It uses Windows paths, but puts quotes on everything
Colors work even with native Windows shell apps
Notes
I considered mintty, but it does not
support colors with native Windows shell apps, ie Git.
superuser.com/questions/184186
Console is nice but it is very slow

Resources