我可以在终端中执行写在文本文档中的命令吗

Can I execute commands written in a textdocument in the terminal

这可能是一个非常简单的问题,但是在从 windows 切换到 linux 之后(并且被迫使用 shell 方式...比我以前更频繁被迫 windows),我还有很多新东西要学。

我在我的笔记本电脑上使用 fedora 25 作为我的 "surf and work" 系统。所以我想安装 Spotify,以便能够听音乐。

要安装软件,我必须执行 4 个命令:

1.添加 Spotify 存储库签名密钥以便能够验证下载的包

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886

2。添加 Spotify 存储库

echo deb http://repository.spotify.com 稳定非免费 | sudo tee /etc/apt/sources.list.d/spotify.list

3。更新可用包列表

sudo apt-get 更新

4.安装 Spotify

sudo apt-get install spotify-client

我的问题:我可以将这些命令写入文本文档并作为脚本执行吗?

我用 chmod 试过了,但我就是不能正常工作。 I used this link as help (yes, I am from germany ^^)

创建一个文件,其第一行是:

#!/bin/sh

然后把命令放在后面。

给文件添加执行权限:

chmod +x filename

然后 运行 脚本为:

./filename