The Linux operating system has the ability for users to add execution permissions to files. This is especially important for scripts, program executables, and other type of files, as these may need execute permissions for proper functioning. This brief tutorial explains how to set up execution permissions for files in Linux systems.
Before granting execute permissions to a file, it is important to know how this works in Linux. By default, files are treated as one of three distinct types: Regular files, directories, or symbolic links. In order to grant execute permission to a file, it must be a regular file (not a directory or a link). Also, user should be aware that the execute permission is set in the form of three bits, and can be set also for the owner (the user that owns the file), the group, or all users (also known as “others”).
To set an execute permission bit for a file, user can use the chmod Command in the following way:
chmod +x filename
If user wants to set the execute permission bit for the group or others, it can be done by adding a “g” or “o” switch to the command, respectively.
chmod g+x filename chmod o+x filename
If user needs to add execution permissions to every file in a directory (and all subdirectories if recursive is used), user can use the find command in combination with the chmod command, as shown:
find ./directory -type f -exec chmod +x {} \;
Above command adds execute permission to all files located in my_directory directory and all its subdirectories.
For other types of permissions, user can also use the chmod command. To make the file only writable by its owner, user can use the following command:

chmod u=rw filename
To make a file executable, readable and writable only by its owner (and no one else):
chmod u=rwx filename
In fact, there are many other variations of the chmod command. To see the full syntax, user can type man chmod, or look up different tutorials on the Web.
Setting execute permissions for files in Linux can be very useful for enabling users to run programs and scripts. Remember that the execute permission bit must be set for regular files, not directories or links. Using the chmod command and its switches, user can add execute permissions to files, as well as other types of permissions such as read, write or execute.
香港服务器首选树叶云,2H2G首月10元开通。树叶云(shuyeidc.com)提供简单好用,价格厚道的香港/美国云 服务器 和独立服务器。IDC+ISP+ICP资质。ARIN和APNIC会员。成熟技术团队15年行业经验。
怎样把文本写的脚本在Linux下运行
首先,用ssh或者telnet远程登陆linux,然后touch 一个脚本名(脚本以“”为后缀),然后vi编辑这个脚本,把在文本写好的脚本内容复制黏贴到这个脚本中(vi的编辑,进到里面后,按“i”是输入,等黏贴完后按一下esc键然后按:输入“wq”,这样就保存退出了。 运行方法是sh 刚才新建的脚本名。 关于这个linux系统的学习,我一直看刘遄老师的书籍《linux就该这么学》。
linux的简单打开命令
linux下的文件必须要先获得可执行权限才能执行,使用ls -lrt命令查看文件是否有可执行权限,r代表可读,w代表可写,z代表可执行,使用root用户登陆命令行后,可以使用chmod命令改变文件使用权限,可以用chmod 777 <文件名>来夺得文件的完整权限.在获得可执行权限后,可以在文件所在目录下使用./<文件名>来执行文件文件是配置文件,一般使用文本查看器可以查看文件,在linux下使用more <文件名>或者cat <文件名>就可以查看了.如果要编辑使用vi编辑器就可以编辑了,具体方法:vi <文件名>
LINUX系统的常用命令,最好能有一些例子的演示..
管理文件和目录的命令ls 列出目录下的内容 常用参数有 -a 显示指定目录下所有目录与文件,包括隐藏文件ln 连接一个文件 常用参数有 -s 表示是符号连接,如果不用参数则是硬连接 显示文件内容或连接两个或多个文件 如#cat 则显示出文件的内容#cat filea fileb > fileC 表示把文件filea和fileb的内容合并在filec中more 分布显示文件内容 常用参数有-p 显示下一屏之前先清屏 -d 在底部提示信息 删除一个文件 常用参数有 -i 交互式操作,则在执行操作前会提示你 -f 和 -i相反一点也不提示cp 复制文件或目录到另一个文件或目录rm 删除一个目录中的一个或多个文件和目录 常用参数有-i 交互式操作,则在执行操作前会提示你 -f 和 -i相反一点也不提示mkdir 创建一个目录 常用参数有-m 对新目录设置权限,-p表示要创建的路径名称rmdir 删除目录 常用参数有-p 删除所有该目录及子目录.文件系统和磁盘空间的命令df 磁盘空间检查du 显示磁盘空间的使用情况find 搜索文件,并执行指定的操作,功能强大 挂载文件系统umount 卸载文件系统文件备份和压缩命令tar 为文件目录创建档案,打包文件,解压和压缩文件,常用参数有 -zxvf解压文件 -cvf压缩文件用户管理及设定权限命令dduser 新增用户chmod 修改文件/目录的属性语法 chmod [who] [+ - =] [mode] 文件名who 可以是u 用户 g 组 o 其他 a 表示所有用户,系统默认值+ 添加某个权限 -取消某个权限 = 赋予指定权限并取消其他所有权限mode可以是r 可读 w 可写 x 可执行 如#chmod ug +w,o-x text 设定文件text的属性为,文件属主(u)增加写权限,与文件属主同组用户(g)增加写权限,其他用户(o)删除执行权限还有一种是数字设定法0表示没有权限,1表示可执行权限,2表示可写出权限,4表示可读权限,然后将其相加,其顺序是(u)(g)(o) 如:#chmod 777 设定它的属性为文件属主、同组用户、其他人可读可写可执行chown 语法:chown [选项] 用户或组 文件或目录参数 -R 改变指定目录及其所有子目录和文件的属主-v显示chown命令所做的工作su 让普通用户拥有超级用户或其他用户的权限 语法: su [选项][用户账号],参数:-c执行一个命令后就结束who 查看当前登录的用户情况wall 对全部已登录用户发送信息write 向系统某个用户发送信息查看系统信息命令shutdown 正常关机ps 查看目前程序执行的情况 参数 -auxtop 查看目前程序执行情况和内存使用情况kill 关闭一个正在执行的程序uname 查看核心版本uptime 查看系统负载free 查看目前内存的使用情况网络操作命令ftp 传送文件telnet 连接到其他计算机netstat 查看网络状况finger 查询某个用户的数据ping 查询某个机器是否开着希望楼主常用google 或 网络:///search?q=LINUX%CF%B5%CD%B3%B5%C4%B3%A3%D3%C3%C3%FC%C1%EE&hl=zh-CN&inlang=zh-CN&ie=GB
发表评论