Adding command shortcuts to binPull a file from a Docker container?ssh asking for passphrase that doesn't have passphraseCan I cheat the docker run -it session by remapping ctrl+p key?qemu2.6 under dockerIs there a way to make a bootable Linux live USB disk from a Linux docker container?Universal way to check if “docker.for.mac.localhost” DNS name is resolvable?Pass environment variable to docker container CMD that evaluates in containerHow to strace all write calls (to stdout/stderr) from all child processes inside a docker container?docker-compose run --rm slow startupWhat is the best way to run a Docker Container? Cron, or other means? With multiple source files it has to pull from?
US born but as a child of foreign diplomat
How can I get people to remember my character's gender?
Copy previous line to current line from text file
Emotional immaturity of comic-book version of superhero Shazam
Can you Ready a Bard spell to release it after using Battle Magic?
Has the Hulk always been able to talk?
Nominativ or Akkusativ
How should I tell my manager I'm not paying for an optional after work event I'm not going to?
Should I dumb down my writing in a foreign country?
Has a commercial or military jet bi-plane ever been manufactured?
IP addresses from public IP block in my LAN
What is the solution to this metapuzzle from a university puzzling column?
Does it make sense for a function to return a rvalue reference
Wrong answer from DSolve when solving a differential equation
How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?
How can I roleplay a follower-type character when I as a player have a leader-type personality?
Causes of bimodal distributions when bootstrapping a meta-analysis model
60s/70s science fiction novel where a man (after years of trying) finally succeeds to make a coin levitate by sheer concentration
I need a disease
What does "Managed by Windows" do in the Power options for network connection?
Floor of Riemann zeta function
Are the Night's Watch still required?
What does this wavy downward arrow preceding a piano chord mean?
Is there an official reason for not adding a post-credits scene?
Adding command shortcuts to bin
Pull a file from a Docker container?ssh asking for passphrase that doesn't have passphraseCan I cheat the docker run -it session by remapping ctrl+p key?qemu2.6 under dockerIs there a way to make a bootable Linux live USB disk from a Linux docker container?Universal way to check if “docker.for.mac.localhost” DNS name is resolvable?Pass environment variable to docker container CMD that evaluates in containerHow to strace all write calls (to stdout/stderr) from all child processes inside a docker container?docker-compose run --rm slow startupWhat is the best way to run a Docker Container? Cron, or other means? With multiple source files it has to pull from?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is there any way to add custom commands to /bin?
For example, I use "docker container ls" a lot, and would like to turn this into a shortcut command, like "dcls."
if I add a file named "dcls" to /bin and inside the file, specify the exact command "docker container ls," i assume this wouldn't work.
What is the right way, if there is one, to do something like this?
ubuntu command-line docker
New contributor
add a comment |
Is there any way to add custom commands to /bin?
For example, I use "docker container ls" a lot, and would like to turn this into a shortcut command, like "dcls."
if I add a file named "dcls" to /bin and inside the file, specify the exact command "docker container ls," i assume this wouldn't work.
What is the right way, if there is one, to do something like this?
ubuntu command-line docker
New contributor
add a comment |
Is there any way to add custom commands to /bin?
For example, I use "docker container ls" a lot, and would like to turn this into a shortcut command, like "dcls."
if I add a file named "dcls" to /bin and inside the file, specify the exact command "docker container ls," i assume this wouldn't work.
What is the right way, if there is one, to do something like this?
ubuntu command-line docker
New contributor
Is there any way to add custom commands to /bin?
For example, I use "docker container ls" a lot, and would like to turn this into a shortcut command, like "dcls."
if I add a file named "dcls" to /bin and inside the file, specify the exact command "docker container ls," i assume this wouldn't work.
What is the right way, if there is one, to do something like this?
ubuntu command-line docker
ubuntu command-line docker
New contributor
New contributor
New contributor
asked 1 hour ago
alex067alex067
1083
1083
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
1 hour ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
57 mins ago
Cheers for your help, got it working!
– alex067
56 mins ago
add a comment |
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
11 mins ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f516870%2fadding-command-shortcuts-to-bin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
1 hour ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
57 mins ago
Cheers for your help, got it working!
– alex067
56 mins ago
add a comment |
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
1 hour ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
57 mins ago
Cheers for your help, got it working!
– alex067
56 mins ago
add a comment |
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
answered 1 hour ago
FreddyFreddy
2,525312
2,525312
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
1 hour ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
57 mins ago
Cheers for your help, got it working!
– alex067
56 mins ago
add a comment |
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
1 hour ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
57 mins ago
Cheers for your help, got it working!
– alex067
56 mins ago
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
1
You have to save it in your user's shell startup file
~/.bashrc
or ~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.– Freddy
1 hour ago
You have to save it in your user's shell startup file
~/.bashrc
or ~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
1 hour ago
Really? What an odd server! If you use bash, you can create it using
echo "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with . ~/.bashrc
or logout and login again.– Freddy
57 mins ago
Really? What an odd server! If you use bash, you can create it using
echo "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with . ~/.bashrc
or logout and login again.– Freddy
57 mins ago
Cheers for your help, got it working!
– alex067
56 mins ago
Cheers for your help, got it working!
– alex067
56 mins ago
add a comment |
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
11 mins ago
add a comment |
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
11 mins ago
add a comment |
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
answered 25 mins ago
G-ManG-Man
14k93871
14k93871
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
11 mins ago
add a comment |
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
11 mins ago
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
11 mins ago
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
11 mins ago
add a comment |
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f516870%2fadding-command-shortcuts-to-bin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown