I am using Ubuntu (Linux mint). There is a mouse option, if I right-click on a file, I can then choose to pin a file (inside its folder), so that whatever file arranging method (alphabetical, by-date, etc) the pinned file will always appear at the beginning of the folder. I looked online to find out if this can be done from command-line, couldn't find anything. Also pin is not a command in Linux. Any ideas? Thanks for any help.

  • 1
    I haven't heard of a way to do this in a shell terminal. It may just be a feature of that particular desktop environment. I mean, technically, there's no reason you couldn't look at the source code to see how the DE is doing that and then modify the ls command to do the same, but I'm not aware of anything built-in.
    – Time4Tea
    Jul 13, 2023 at 11:32
  • 2
    Any feature like that would be specific to the program in question, though in GUI, some programs might use a common dialog for choosing files to open or save (though on Linux systems, I'd expect those to be provided by the toolkit, not the wider OS as such, unlike e.g. on macOS where pretty much everything uses the same file open dialog). While an implementation of ls could support something like that, I doubt you're going to find one, since it would involve saving the pins somewhere, and another tool for setting them etc. Stuff that a regular ls has no need at all for.
    – ilkkachu
    Jul 13, 2023 at 12:20
  • 1
    I suppose the usual workaround would be to rename the file into something that makes it appear first in a list without any software changes, perhaps something like !README.TXT, but the sorting order also depends on the locale...
    – ilkkachu
    Jul 13, 2023 at 12:21
  • 1
    You could write a script in ~/bin that overrides ls to list certain files in a directory before others. One solution would be to have a .pinned file or directory in each directory that has "pinned" files. The script would list the files in "pinned" first, then list the rest in the normal manner. You would need to make sure your ~/bin comes before /usr/bin in the PATH variable, usually done in .profile (or the equivalent config for the shell you use).
    – pell
    Jul 14, 2023 at 16:00
  • By the way, I'm not recommending overriding ls in the way I posted above, but it is a possibility. Or you could write a script with a different name that calls ls and does what I suggested above.
    – pell
    Jul 14, 2023 at 16:08

2 Answers 2


as you said, pin is not a command and this functionality doesn't work in command line. In other words, Linux files have no attributes for this.

I think your file manager, maybe Nautilus in case of Mint?! uses an upper layer to indicate these desired files.

  • Hmm, I see. I found a way to manipulate the Linuxmint file manager (Nemo) to get what I want; would add it as an answer soon.
    – mahbubweb
    Jul 14, 2023 at 15:31

The command is

gio set /path/to/file/ metadata::pinned-to-top true

If one is in the folder containing the file this command wouldn't seem to take effect, but after refreshing the folder one can see the change.

I wonder how to refresh using command line, couldn't find anything on google. Maybe someone can answer in the comments, I am reluctant to ask another question.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .