I need help getting the right command - salt-stack

I have a list of minions I need to know the OS I don't know the command to use my list. I see people using this command salt '*' grains.item os but I need something like this: salt "my list" grains.item OS

It depends what kind of list you mean. There are multiple ways to target different minions.
salt -E 'minion1|minion2|minion3' grains.item os

Related

Is there a way to run "sys.list_modules" command without a minion?

As far as the documentation goes, if one would like to query for available execution modules, the following command should be used:
salt '<minion_name>' sys.list_modules
My question is,
- whether it possible to run the above without a minion?
(e.g salt sys.list_modules , isn't it cleaner?)
If you just want to know all the modules available to you, or the latest modules available for the current saltstack version.
salt-call --local sys.list_modules

Run Command Whenever ANY Other Command is Run

I have a very unnecessary scripting question: how can I make the command fortune run along with any other command? So, for example, instead of running
something
I want to ALWAYS force run something similar, but not exactly
fortune && something
wherein the fortune command finishes before the other command begins.
Is there a way to do this in Mac OS X Yosemite?
I don't know exactly what you are trying to achieve.
But you can try below:
eg. you want to fire 'hostname' and 'pwd' whenever 'hostname' command is fired.
Add below line in your bash profile.
alias hostname="hostname;pwd;"
you will get output like below:
[user#host ~] hostname
host1.example.com
/data/data2/new

How do I test a Unix command?

I want to test a unix command. More specifically the "Cat" command. I want to be able to get test data for this.
How do I go about doing this?
(Newbie to computer science)
I'll be using terminal
Depending on the operating system you are on you could type this in a command prompt or terminal.
If you are on OSX or a Linux derivative you'll need the terminal, if you are on Windows you'll need Cygwin to perform this action.
When you want to test commands that are possibly dangerous it's always best to try these in a virtual environment like Virtual Box
You could use any data for the cat command, if you're setup you could use the /etc/issue file with cat /etc/issue to print your distribution information (This is GNU/Linux specific).
Be sure to read the CAT manual page

How do you share zsh history between multiple machines?

I have a setup I'm pretty happy with for sharing my configuration files between machines, but I find that I often want to search back in zsh (Ctrl + R) and I can't remember which machine I typed the command on. Ideally I'd like this to search a canonical de-duped list of previous commands from any of my machines. Given that I sometimes work on these machines concurrently and without a network connection, what's a sensible way of merging history files and keeping everything in sync?
I wrote this plugin for oh-my-zsh:
An Oh My Zsh plugin for GPG encrypted, Internet synchronized Zsh history using Git
https://github.com/wulfgarpro/history-sync
Hmm, I guess you could identify your accounts somehow... then you could do the following:
modify your .zshrc to catenate the history of the OTHER accounts from dropbox or SCM with the current history IF this is the first zsh launched on the current computer
then sort the entries with -n (sort by timestamp)
I guess zsh would remove the duplicates if you have setopt HIST_SAVE_NO_DUPS
Then you need to trap shell exit, and copy the existing history to the dropbox/SCM/whatever shared place.
You could have a NFS mount point for the involved machines with the .zsh_history in it. Each machine would need the HISTFILE env var set to that file path in the NFS.
HISTFILE env var is compulsory, since ZSH does not accept a symlink, and it would be replaced by a file using the last version of the symlink target.
I have not tested what is said above, since my setup is between VM's using OSX and Parallels shared folders. Hence, with NFS the integrity (order?) of the file could be something to consider, also VS the Dropbox solution.
Not sure, something like https://gist.github.com/elim/f77e3e9f06b6f8a5e788 could be used to fix versions to be merged...
I use the command below:
ssh username#example.com cat ~/.zsh/.zhistory | cat ~/.zsh/.zhistory - | sort | uniq | tee ~/.zsh/.zhistory | ssh username#example.com cat \> ~/.zsh/.zhistory

Navigation in Terminal

Simple one here guys, I remember there was a key that you could press in terminal to fill out the folder name for you when changing directory, saving you have to type out a huge folder name and escaping in the spaces.
cd mydir/ccp... ..... .......
I can't find it on google, does anyone know the key/key command I'm taking about?
Are you talking about completion? In bash (any many other shells) Tab is the key for completion.
Its the TAB key (assuming you are using bash shell in Terminal on Mac OS X).

Resources