Listing which files Terminal opens at load time - linux

When I open Terminal I would like to know which files are being loaded (e.g .bashrc, .bash_profile etc). Although I'm doing this in OSX, I guess it's also relevant to logging in via SSH to a Linux server.
Is there any way I can log this out or to check the files loaded?

You could use the fs_usage tool, which "presents an ongoing display of system call usage information pertaining to filesystem activity".
Alternatively, the opensnoop tool which, as the description states "tracks file opens. As a process issues a file open, details such as UID, PID and pathname are printed out"

Related

How to monitor a directory for file changes without using inotifywait?

I require a VM for developing and my host is where my IDE is. I have discovered that inotifywait does not work with shared folders, as I am sharing a local folder with my Linux guest using Virtual Box.
Basically, I have a simple bash script which needs to watch a directory and wait for any file changes. Inotifywait would be the best option but I cannot get it to work with my shared folder.
I was wondering if there is another option for my problem?
Depending on the sizes of the files and the nature of the changes you could:
Create a checksum (md5, CRC, SHA256) of the files and watch for changes
check the size of the files and watch for changes

Tab button in ftp command

I usually use "TAB" button to help me do typing in linux or AIX command, for example, I have a file with file name is abcdefg.txt, so when I want to vi to this file, I just type vi ab then press the "TAB" button in my keyboard, then it will automatically help me search for abcdefg.txt (only have 1 file which is name start with ab).
However, when I ftp to the environment, I can not use "TAB" button, I need to fully type the whole file name. Please advise me how to do this in ftp environment.
Second problem, in ftp environment, when I list all the files in the directory, I saw a file which name is 123456789.txt, however, when I want to rename it like:
rename 123456789.txt 123456789a.txt
it prompt me 550 123456789.txt: A file or directory in the path name does not exist.
But I can rename the other files. I suspect this 123456789.txt file name got some space in some where, that's why I hit the error.
Most FTP programs, especially those which come with proprietary Unices like AIX or HP-UX don't offer readline support. Install a more powerful tool like ncftp to fix this.
To rename files with whitespace, you can try to quote the file name but again, this might fail with bare-bones FTP clients.
When just downloading the file, there is a simple workaround: Use your browser. Every browser supports the ftp:// protocol. The main problem here is security: You have to pass the password via the URL: ftp://user:password#host/ so the browser will put it into its history.
But since you use FTP, security isn't a concern anyway (FTP transmits the password as plain text over the wire, so everyone on the same network can see it).
Another option is mucommander, a cross platform file manager which supports a wide range of protocols and which handles spaces in file names correctly.

Creating a menu item generically in Linux

For part of a large university project I have built a large java based application. To make "installation" cleaner I am aiming to write a script to copy the jar to a hidden file in the users home directory then add a menu &/Or desktop launcher.
Since I do not know what platform the markers shall be using it seems sensible to make this generic so I was going to build a shell script and a batch file.
The shell script starts off simple, check the directory doesnt already exist, make it and copy the file accross.
Then it comes to making a launcher of some kind. I presume each desktop environment shall do things differently.
After 10 minutes with google it seems everything suggested is autotools but since I have no knowledge of this it seems a bit overkill.
Is there an easy way to achieve what i need?
Thanks
These days, basically all of the desktop environments uses desktop files. For the specification for those files, see the Desktop Entry Specification.
Normally, they're put in /usr/share/applications on the system. Those files are then read and used to construct the menu.
If you have the ability to write to the system /usr/share/applications directory, that's obviously simplest, but if you had that, you would probably be putting the JAR file somewhere other than a hidden directory in the user's home directory.
If not, the path that's supposed to be honored is ~/.local/share/applications. If you drop a desktop file in there, it should show up for the user. (This is somewhat newer; I don't think GNOME 2 supports, it for example. Older desktop environments had various special places for these files.)
Then, the problem basically reduces to figuring out what to write for the Exec line in the desktop file. (See the desktop files on your system in /usr/share/applications for some examples.) If you're lucky, you can get away with just sticking a java command in there, but the details will depend on your application.

Automated Context Switching Between Projects via SSH and Multiple Terminals

I'm looking for some guidance on an approach to automate the process of quickly switching between projects.
Putty Windows (2 of them):
Vim with project.session open (multiple tabs)
IPython open to the working directory of the project
What I want to automate in its respective windows:
Save all files, save session, close vim, change working directory of vim to next project, open related project session.
Close ipython (as I often restart it during development and want a fresh instance), change directory to next project'ss location, open a new ipython
A magic solution would be a single command that would change the state of both putty windows. However, since I have no idea how that would be done my current approach would be:
Attempt to figure out how to bind all that Vim stuff to a key press or a custom vim script that is used like: :SwitchProj "projectName"
Write a bash script or find a bash command that will allow me to type as little as possible to perform the directory switch and open new ipython interpreter.
As I have very little experience on Linux and SSH I would be interested to know how other's have solved this problem or would approach it!
I believe that the Linux screen command should satisfy you. Google gives you many tutorials, like this one.
I sadly confess that I am not very familiar with screen. Learning it is in my todo list
If you use the Gnu Emacs editor, you can also open many shell buffers inside (and other interactive buffers, like gdb sessions, compilations, grep search) and edit many files. I do that very often. You can use emacs thru a tty interface, such as provided by ssh.
You could also use ssh with e.g. -X to also redirect X11 windowing. For you, that means that you'll need to run an X11 server on your local Windows machine.

Compatibility of x-www-browser

I want to open html files from a shell script. I know that Ubuntu has a command x-www-browser that will open the default browser on the system. I also found via some Googling that the command is part of the debian system. I was wondering if the command is available on non debian based distros. If it isn't is there a standard way of opening an html file in the default browser on a linux OS via command line? Note that I'm using Bash.
If you are wanting to open an HTML file that is local (and maybe even remote, I'd have to check), you can use xdg-open. This is the rough equivalent to "double-clicking" on a file to open it, so it's not limited to html files. Since you want to always open in the user's default browser, this would be the same as if they just opened it themselves.
Of course, if they have their system set up to have HTML files open in a text editor (like I did for awhile), this would backfire. But that's pretty rare.
Quick update
I just checked and xdg-open http://google.com brought up Google in Firefox (my default browser). So it does work for non-local files.
You could use xdg-open.

Resources