<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[小技巧]]></title><description><![CDATA[小技巧]]></description><link>http://an.forum.genostack.com/category/5</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 14:43:29 GMT</lastBuildDate><atom:link href="http://an.forum.genostack.com/category/5.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Jan 2025 06:01:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[升级cmake 到 3.11]]></title><description><![CDATA[<h1>Removing the old cmake</h1>
<p dir="auto">sudo apt purge cmake<br />
sudo apt autoremove</p>
<h1>Downloading the new</h1>
<p dir="auto"><a href="https://cmake.org/files/v3.11/cmake-3.11.1-Linux-x86_64.sh" rel="nofollow ugc">https://cmake.org/files/v3.11/cmake-3.11.1-Linux-x86_64.sh</a><br />
sudo mkdir /opt/cmake<br />
sudo sh cmake-3.11.1-Linux-x86_64.sh --prefix=/opt/cmake --skip-license</p>
<h1>Make it available</h1>
<p dir="auto">sudo update-alternatives --install /usr/bin/cmake cmake /opt/cmake/bin/cmake 1 --force</p>
]]></description><link>http://an.forum.genostack.com/topic/1118/升级cmake-到-3-11</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/1118/升级cmake-到-3-11</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Mon, 13 Jan 2025 06:01:37 GMT</pubDate></item><item><title><![CDATA[对多个文件进行批量改名]]></title><description><![CDATA[<p dir="auto">for f in *.rg.bam; do mv "$f" "${f/rg.bam/bam}";done<br />
解释：将rg.bam 结尾的文件改为 bam结尾<br />
${f/} f是前面的变量 保存的文件名</p>
]]></description><link>http://an.forum.genostack.com/topic/1113/对多个文件进行批量改名</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/1113/对多个文件进行批量改名</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Tue, 03 Dec 2024 02:07:49 GMT</pubDate></item><item><title><![CDATA[从阿里oss 直接下载数据]]></title><description><![CDATA[<p dir="auto">1.某测序公司给的数据在阿里云 需要使用oss browser 下载<br />
<img src="/assets/uploads/files/1731760490428-4313d488-9e16-4c84-bd27-5b60174c551f-image.png" alt="4313d488-9e16-4c84-bd27-5b60174c551f-image.png" class=" img-responsive img-markdown" /><br />
该软件可以获取一个外部链接 使用该链接可以直接下载数据<br />
2.该链接较长 有特殊字符 需要使用''括起来</p>
<pre><code>wget 'https://annoroad-cloud-product.oss-cn-beijing.aliyuncs.com/user/cache/project/XS01KF2023110197/PM-XS01KF2023110197-15/ANNO_XS01KF2023110197_PM-XS01KF2023110197-15_2024-11-15/Cleandata/DNA-ZM3/DNA-ZM3_R1.fq.gz?OSSAccessKeyId=LTAI4G7bDDSRkyJhvK1vsUyE&amp;Expires=1731763573&amp;Signature=W2FD94gWBUQjeni8YSd2Rcgs6YE%3D'
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/1108/从阿里oss-直接下载数据</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/1108/从阿里oss-直接下载数据</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Sat, 16 Nov 2024 12:36:01 GMT</pubDate></item><item><title><![CDATA[R 在jupyter中提示killed]]></title><description><![CDATA[<p dir="auto">在docker中执行<br />
cat /sys/fs/cgroup/memory/memory.limit_in_bytes<br />
查看内存限制</p>
]]></description><link>http://an.forum.genostack.com/topic/1089/r-在jupyter中提示killed</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/1089/r-在jupyter中提示killed</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Wed, 28 Aug 2024 08:21:11 GMT</pubDate></item><item><title><![CDATA[Linux 网络命令]]></title><description><![CDATA[<p dir="auto">显示防火墙的数据 查询哪个规则生效了<br />
iptables -L -v -n</p>
]]></description><link>http://an.forum.genostack.com/topic/1084/linux-网络命令</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/1084/linux-网络命令</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Wed, 26 Jun 2024 07:50:13 GMT</pubDate></item><item><title><![CDATA[k8s 常用命令]]></title><description><![CDATA[<p dir="auto"><a href="https://www.digitalocean.com/community/tutorials/how-to-inspect-kubernetes-networking" rel="nofollow ugc">https://www.digitalocean.com/community/tutorials/how-to-inspect-kubernetes-networking</a></p>
<p dir="auto">k8s网络</p>
]]></description><link>http://an.forum.genostack.com/topic/1081/k8s-常用命令</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/1081/k8s-常用命令</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Mon, 24 Jun 2024 08:06:50 GMT</pubDate></item><item><title><![CDATA[FASTA&#x2F;Q序列操作神器:seqkit]]></title><description><![CDATA[<h4>0. 简介</h4>
<p dir="auto">seqkit：序列梳理神器-统计、格式转换、长度筛选、质量值转换、翻译、反向互补、抽样、去重、滑窗、拆分等30项全能</p>
<h4>1. 安装</h4>
<pre><code>conda install -c bioconda seqkit
</code></pre>
<h4>2.  功能</h4>
<pre><code>amplicon        通过引物检索扩增子(或其周围的特定区域)
bam             检查和在线绘制BAM记录文件的直方图
common          通过id/名称/序列查找多个文件的公共序列
concat          连接多个文件中具有相同ID的序列
convert         转换FASTQ质量编码格式：支持格式包括：桑格，Solexa和Illumina
duplicate       重复序列N次
faidx           创建FASTA索引文件并提取子序列
fish            使用局部比对在较大的序列中寻找短序列
fq2fa           转换FASTQ到FASTA
fx2tab          将FASTA/Q转换为表格格式(包含长度/GC含量/GC偏好)
genautocomplete 生成shell自动完成脚本
grep            通过ID/name/sequence/sequence motif搜索序列，允许错配
head            打印第一条序列
help            打印帮助信息
locate          定位序列，或者motifs，允许错配
mutate          编辑序列(点突变、插入、删除)
pair            匹配双端序列文件
range           打印一个范围内的序列
rename          重命名重复序列ID
replace         使用正则表达式修改名称或者序列
restart         重置环状基因组的起始位置
rmdup           通过id/名称/序列删除重复的序列
sample          按数量或比例对序列进行抽样
sana            清理损坏的单行fastq文件
scat            real time recursive concatenation and streaming of fastx files
seq             转换序列(反向，补充，提取ID…)
shuffle         随机序列
sliding         序列滑窗提取，支持环形基因组
sort            按id/名称/序列/长度排序序列
split           按id/seq区域/大小/部件将序列拆分为文件(主要用于FASTA)
split2          按序列数量/文件数将序列拆分为多个文件(FASTA, PE/SE FASTQ)
stats           FASTA/Q文件的简单统计
subseq          通过region/gtf/bed得到子序列，包括侧翼序列
tab2fx          转换表格格式为FASTA/Q格式
translate       翻译DNA/RNA到蛋白质序列(支持歧义碱基)
version         打印版本信息并检查是否更新
watch           序列特征的监测和在线直方图

</code></pre>
<h5>参数</h5>
<pre><code>Flags:
      --alphabet-guess-seq-length int   seqkit根据第一个FASTA记录猜测序列类型的序列前缀的长度(0表示整个序列)(默认10000)
  -h, --help                            显示帮助
      --id-ncbi                         FASTA头是ncbi风格的，例如&gt;gi|110645304|ref|NC_002516.2 
      --id-regexp string                用于解析ID的正则表达式(default "^(\\S+)\\s?")，匹配空格前的部分为序列名
      --infile-list string              输入文件列表中的文件 (one file per line), if given, they are appended to files from cli arguments
  -w, --line-width int                  输出FASTA格式时的行宽 (0 for no wrap) (default 60)
  -o, --out-file string                 输出 ("-" for stdout, suffix .gz for gzipped out) (default "-") -代表标准输出，加.gz可输出压缩文件
      --quiet                           保持安静，不要显示额外的信息
  -t, --seq-type string                 序列类型 (dna|rna|protein|unlimit|auto) (auto, 按第一个序列自动检测) (default "auto")
  -j, --threads int                     CPU数量 (默认单核为1，多核为2) (default 2)
</code></pre>
<h4>参考</h4>
<p dir="auto"><a href="https://bioinf.shenwei.me/seqkit/" rel="nofollow ugc">https://bioinf.shenwei.me/seqkit/</a><br />
<a href="https://mp.weixin.qq.com/s/OJsxFR33ej0ACozNbF_dNA" rel="nofollow ugc">https://mp.weixin.qq.com/s/OJsxFR33ej0ACozNbF_dNA</a></p>
]]></description><link>http://an.forum.genostack.com/topic/994/fasta-q序列操作神器-seqkit</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/994/fasta-q序列操作神器-seqkit</guid><dc:creator><![CDATA[mengpf]]></dc:creator><pubDate>Wed, 06 Sep 2023 08:29:29 GMT</pubDate></item><item><title><![CDATA[命令行中 -- 的作用]]></title><description><![CDATA[<p dir="auto"><a href="https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean" rel="nofollow ugc">https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean</a></p>
]]></description><link>http://an.forum.genostack.com/topic/973/命令行中-的作用</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/973/命令行中-的作用</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Sat, 22 Jul 2023 02:44:27 GMT</pubDate></item><item><title><![CDATA[Check all Checkboxes in Page via Developer Tools]]></title><description><![CDATA[<p dir="auto"><a href="https://stackoverflow.com/questions/14245769/check-all-checkboxes-in-page-via-developer-tools" rel="nofollow ugc">https://stackoverflow.com/questions/14245769/check-all-checkboxes-in-page-via-developer-tools</a></p>
<pre><code>(function() {
    var aa= document.getElementsByTagName("input");
    for (var i =0; i &lt; aa.length; i++){
        if (aa[i].type == 'checkbox')
            aa[i].checked = true;
    }
})()
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/901/check-all-checkboxes-in-page-via-developer-tools</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/901/check-all-checkboxes-in-page-via-developer-tools</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Tue, 23 May 2023 06:10:46 GMT</pubDate></item><item><title><![CDATA[install.packages(&#x27;ncdf4&#x27;)报错]]></title><description><![CDATA[<p dir="auto">ERROR: configuration failed for package ‘ncdf4’<br />
sudo apt-get update -y<br />
sudo apt-get install -y libnetcdf-dev</p>
]]></description><link>http://an.forum.genostack.com/topic/796/install-packages-ncdf4-报错</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/796/install-packages-ncdf4-报错</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Fri, 27 Jan 2023 08:46:51 GMT</pubDate></item><item><title><![CDATA[samba]]></title><description><![CDATA[<p dir="auto">docker run -it  -p 139:139 -p 445:445 -v /home/genostack/share:/mount -d dperson/samba -u "samba;samba" -s "shared;/mount;yes;no;no;all;none"<br />
docker exec -it 容器ID /bin/bash<br />
smbpasswd -a samba 命令添加用户，并设置密码为samba</p>
]]></description><link>http://an.forum.genostack.com/topic/699/samba</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/699/samba</guid><dc:creator><![CDATA[zhanglu]]></dc:creator><pubDate>Thu, 23 Jun 2022 10:42:12 GMT</pubDate></item><item><title><![CDATA[windows storage server 2016 NFS 配置]]></title><description><![CDATA[<p dir="auto">Share and Storage Management</p>
<p dir="auto">Start Share and Storage Management.</p>
<p dir="auto">In the Share and Storage Management console, in the details pane, click the Shares tab, and then click &lt;share_name&gt; (where share_name is the name of the NFS share).</p>
<p dir="auto">In the Actions pane, click Properties.</p>
<p dir="auto">The &lt;share_name&gt; Properties dialog box displays.</p>
<p dir="auto">In the &lt;share_name&gt; Properties dialog box, on the NFS Authentication tab, select the Enable unmapped user access check box.</p>
<p dir="auto">On the NFS Authentication tab, click Allow unmapped UNIX user access, and then click OK.</p>
<p dir="auto">Close the Share and Storage Management console.</p>
]]></description><link>http://an.forum.genostack.com/topic/698/windows-storage-server-2016-nfs-配置</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/698/windows-storage-server-2016-nfs-配置</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Thu, 23 Jun 2022 08:28:50 GMT</pubDate></item><item><title><![CDATA[Java 远程调试]]></title><description><![CDATA[<p dir="auto"><a href="https://medium.com/@dmytro.de/the-java-debugger-how-to-debug-java-without-ide-how-to-use-jdb-ef732d79f915" rel="nofollow ugc">https://medium.com/@dmytro.de/the-java-debugger-how-to-debug-java-without-ide-how-to-use-jdb-ef732d79f915</a></p>
]]></description><link>http://an.forum.genostack.com/topic/669/java-远程调试</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/669/java-远程调试</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Wed, 25 May 2022 06:01:11 GMT</pubDate></item><item><title><![CDATA[Delete syslog but size disk can&#x27;t increase]]></title><description><![CDATA[<p dir="auto"><a href="https://serverfault.com/questions/403738/after-deleting-log-files-ubuntu-server-still-saying-there-is-no-space" rel="nofollow ugc">https://serverfault.com/questions/403738/after-deleting-log-files-ubuntu-server-still-saying-there-is-no-space</a></p>
<p dir="auto"><a href="https://access.redhat.com/solutions/2316#:~:text=On%20Linux%20or%20Unix%20systems,to%20occupy%20space%20on%20disk" rel="nofollow ugc">https://access.redhat.com/solutions/2316#:~:text=On Linux or Unix systems,to occupy space on disk</a>.</p>
]]></description><link>http://an.forum.genostack.com/topic/661/delete-syslog-but-size-disk-can-t-increase</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/661/delete-syslog-but-size-disk-can-t-increase</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Mon, 23 May 2022 10:15:05 GMT</pubDate></item><item><title><![CDATA[C&#x2F;C++ segment fault（段错误）定位方法]]></title><description><![CDATA[<p dir="auto">1.打开 core dump<br />
ulimit -c unlimited</p>
<p dir="auto">2.编译程序debug 版本 加上-g -O0   一般在项目的Makefile 中</p>
<p dir="auto">3.gdb 运行程序</p>
<p dir="auto">gdb --args kmer2read_distr --seqid2taxid $DATABASE/seqid2taxid.map --taxonomy $DATABASE/taxonomy/ --kraken $DATABASE/database.kraken --output $DATABASE/database${READ_LEN}mers.kraken -k ${KMER_LEN} -l ${READ_LEN} -t ${THREADS}</p>
]]></description><link>http://an.forum.genostack.com/topic/659/c-c-segment-fault-段错误-定位方法</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/659/c-c-segment-fault-段错误-定位方法</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Wed, 18 May 2022 09:14:26 GMT</pubDate></item><item><title><![CDATA[gnutls_handshake() failed: Error in the pull function]]></title><description><![CDATA[<p dir="auto">git config --global http.sslVerify false</p>
]]></description><link>http://an.forum.genostack.com/topic/656/gnutls_handshake-failed-error-in-the-pull-function</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/656/gnutls_handshake-failed-error-in-the-pull-function</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Tue, 17 May 2022 10:20:10 GMT</pubDate></item><item><title><![CDATA[申请苹果美国id]]></title><description><![CDATA[<p dir="auto"><a href="https://zhuanlan.zhihu.com/p/367821925" rel="nofollow ugc">https://zhuanlan.zhihu.com/p/367821925</a></p>
]]></description><link>http://an.forum.genostack.com/topic/565/申请苹果美国id</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/565/申请苹果美国id</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Wed, 09 Mar 2022 02:41:31 GMT</pubDate></item><item><title><![CDATA[解决Ubuntu上安装chrome浏览器网页空白的问题]]></title><description><![CDATA[<p dir="auto">第1步.在终端输入</p>
<pre><code>/usr/bin/google-chrome-stable
</code></pre>
<p dir="auto">第2步.创建一个google-chrome.desktop的文件</p>
<pre><code>gedit ~/.local/share/applications/google-chrome.desktop
</code></pre>
<p dir="auto">第3步 修改文件</p>
<pre><code>vi ~/.local/share/applications/google-chrome.desktop
Exec=/usr/bin/google-chrome-stable %u
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/504/解决ubuntu上安装chrome浏览器网页空白的问题</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/504/解决ubuntu上安装chrome浏览器网页空白的问题</guid><dc:creator><![CDATA[zhangfanglin]]></dc:creator><pubDate>Thu, 30 Dec 2021 09:45:30 GMT</pubDate></item><item><title><![CDATA[linux ssh 登录报错]]></title><description><![CDATA[<p dir="auto">问题：</p>
<pre><code>Jul 26 09:33:25 anneng01 sshd[6536]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Jul 26 09:33:25 anneng01 sshd[6536]: error: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
Jul 26 09:33:25 anneng01 sshd[6536]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Jul 26 09:33:25 anneng01 sshd[6536]: error: Permissions 0755 for '/etc/ssh/ssh_host_ed25519_key' are too open.
Jul 26 09:33:25 anneng01 sshd[6536]: error: It is required that your private key files are NOT accessible by others.
Jul 26 09:33:25 anneng01 sshd[6536]: error: This private key will be ignored.
Jul 26 09:33:25 anneng01 sshd[6536]: error: key_load_private: bad permissions
Jul 26 09:33:25 anneng01 sshd[6536]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Jul 26 09:33:25 anneng01 sshd[6536]: fatal: No supported key exchange algorithms [preauth]
</code></pre>
<p dir="auto">后台进入服务器</p>
<pre><code>sudo chmod -R 600 /etc/ssh/
systemctl restart sshd
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/362/linux-ssh-登录报错</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/362/linux-ssh-登录报错</guid><dc:creator><![CDATA[zhangfanglin]]></dc:creator><pubDate>Mon, 26 Jul 2021 05:53:35 GMT</pubDate></item><item><title><![CDATA[系统突然报错Too many open files]]></title><description><![CDATA[<p dir="auto">原因修改NGINX配置后重新启动发现系统报错：</p>
<pre><code>Failed to allocate directory watch: Too many open files
</code></pre>
<p dir="auto">解决方案：</p>
<pre><code> sudo vi /etc/sysctl.conf
</code></pre>
<p dir="auto">文件添加：</p>
<pre><code>fs.inotify.max_user_instances=51200
</code></pre>
<p dir="auto">保存成功后：</p>
<pre><code>sudo sysctl -p
</code></pre>
<p dir="auto">将文件生效 重新启动nginx</p>
<pre><code>sudo service  nginx restart
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/343/系统突然报错too-many-open-files</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/343/系统突然报错too-many-open-files</guid><dc:creator><![CDATA[zhangfanglin]]></dc:creator><pubDate>Wed, 14 Jul 2021 06:40:10 GMT</pubDate></item><item><title><![CDATA[nginx 如何代理VUE history模式路由]]></title><description><![CDATA[<p dir="auto">nginx配置如下：</p>
<pre><code>server {
   listen       8022;
   server_name  _;
   root /path/path;
   index index.html;
   location / {
     index index.html index.htm;
     try_files $uri $uri/ @fallback;                                                                       
   }
   location @fallback {
     rewrite ^.*$ /index.html break;
   }
 }
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/332/nginx-如何代理vue-history模式路由</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/332/nginx-如何代理vue-history模式路由</guid><dc:creator><![CDATA[zhangfanglin]]></dc:creator><pubDate>Wed, 23 Jun 2021 06:00:42 GMT</pubDate></item><item><title><![CDATA[sudo 重定向没有权限的几种解决办法]]></title><description><![CDATA[<p dir="auto">Redirect Output to Location With “Permission denied” Error</p>
<ol>
<li>Overview<br />
As we know, we can redirect the standard output (stdout) of a command to a file using the “&gt;” operator in the Linux command line.</li>
</ol>
<p dir="auto">However, sometimes, we want to redirect to a file where we don’t have permission to write — for example, “sudo command &gt; file_requires_root_permission“.</p>
<p dir="auto">In this case, we may get a “Permission denied” error even if we’ve used the sudo command.</p>
<p dir="auto">In this quick tutorial, we’ll analyze the cause of this problem and address the right ways to solve it.</p>
<ol start="2">
<li>Introduction to the Problem<br />
An example is probably the best way to explain the problem.</li>
</ol>
<p dir="auto">Let’s say we have an empty, plain text file:</p>
<p dir="auto">kent$ ls -l /opt/output.txt<br />
-rw-r--r-- 1 root root 0 May  8 10:43 /opt/output.txt<br />
The ls output above shows that only user root can write to the /opt/output.txt file.</p>
<p dir="auto">Now, we attempt to redirect the output of an echo command to the mentioned file as the regular user kent:</p>
<p dir="auto">kent$ echo "Linux is awesome!" &gt; /opt/output.txt<br />
bash: /opt/output.txt: Permission denied<br />
We’ve gotten the “Permission denied” error. It isn’t hard to understand. This is because we execute the echo command and redirect the output as the kent user, but the user kent has no write permission on the file /opt/output.txt.</p>
<p dir="auto">We know if we execute a command with sudo, the command will be executed as the root user. Let’s say the user kent has been granted the sudo privilege.</p>
<p dir="auto">Next, let’s see if we can redirect the echo output to our target file using sudo:</p>
<p dir="auto">kent$ sudo echo "Linux is awesome!" &gt; /opt/output.txt<br />
[sudo] password for kent:<br />
bash: /opt/output.txt: Permission denied<br />
Oops, after we give the password, we keep having the same error message.</p>
<p dir="auto">We may ask why we still don’t have permission to write to the file though we’ve used the sudo command?</p>
<p dir="auto">Next, let’s find the answer to the question.</p>
<ol start="3">
<li>Why Do We Have the “Permission denied” Error?<br />
To answer the question, let’s take a closer look at the whole echo command. The command has two parts:</li>
</ol>
<p dir="auto">The command part: sudo echo “Linux is awesome!”<br />
The redirection part: &gt; /opt/output.txt<br />
The sudo command allows us to execute the echo command as the root user. However, when we write “sudo command &gt; file“, the sudo command won’t affect the redirection part.</p>
<p dir="auto">In other words, the redirection is still performed as the regular user kent. Therefore, we encounter the “Permission denied” error.</p>
<p dir="auto">Now that we understand the cause of the problem, let’s discuss the solutions.</p>
<p dir="auto">We’ll address several different approaches to solve the problem:</p>
<p dir="auto">Launching a “root” shell to execute the command<br />
Wrapping the command in a shell script<br />
Changing the redirection part into a command<br />
Next, let’s look at these three approaches one by one.</p>
<ol start="4">
<li>Launching a “root” Shell to Execute the Command<br />
If we can start a shell logged in as the root user and execute our command in this shell, the redirection will also be done by root.</li>
</ol>
<p dir="auto">We can pass the -s option to the sudo command to have a “root” shell:</p>
<p dir="auto">kent$ sudo -s<br />
[sudo] password for kent:<br />
[root]# echo "Linux is awesome!" &gt; /opt/output.txt<br />
[root]# exit<br />
kent$ cat /opt/output.txt<br />
Linux is awesome!<br />
As the output above shows, after executing sudo -s, we’re in an interactive shell with the root user. Then, we can execute the whole command and redirection as root.</p>
<p dir="auto">The output has also been successfully written to the target file.</p>
<ol start="5">
<li>Wrapping the Command in a Shell Script<br />
If we can turn the command and redirection into a single command, we can execute it with sudo so that the redirection gets done by root.</li>
</ol>
<p dir="auto">Following this idea, we can create a simple shell script file containing our echo command:</p>
<p dir="auto">kent$ cat <a href="http://myScript.sh" rel="nofollow ugc">myScript.sh</a><br />
#!/bin/bash<br />
echo "Linux is awesome! - (shell script)" &gt; /opt/output.txt<br />
Next, let’s empty the /opt/output.txt file and test our <a href="http://myScript.sh" rel="nofollow ugc">myScript.sh</a>:</p>
<p dir="auto">kent$ sudo ./myScript.sh<br />
[sudo] password for kent:<br />
kent$ cat /opt/output.txt<br />
Linux is awesome! - (shell script)<br />
Our shell script works as we expected.</p>
<p dir="auto">However, it can be inconvenient if we always have to create shell script files for commands with redirections.</p>
<p dir="auto">If we want to execute such a command only once quickly, we can use sudo bash -c “Command &gt; file” to execute the command with redirection in a sub-shell so that the root user performs both the command and the redirection:</p>
<p dir="auto">kent$ sudo bash -c 'echo "Linux is awesome! - (sub-shell)" &gt; /opt/output.txt'<br />
[sudo] password for kent:<br />
kent$ cat /opt/output.txt<br />
Linux is awesome! - (sub-shell)<br />
6. Changing the Redirection Into a Command<br />
We’ve learned from a previous section that the sudo command won’t affect the redirection part. However, if we can change the redirection into a command, we can execute it with sudo once again.</p>
<p dir="auto">The tee command is exactly what we are looking for. tee allows us to redirect the input to a file and stdout. Further, we can launch “sudo tee …” to cause the tee command to be executed as the root user.</p>
<p dir="auto">Next, let’s test this approach with our example:</p>
<p dir="auto">kent$ sudo echo "Linux is awesome! - (using tee)" | sudo tee /opt/output.txt &gt;/dev/null<br />
[sudo] password for kent:<br />
kent$ cat /opt/output.txt<br />
Linux is awesome! - (using tee)<br />
As the example above shows, we’ve written the expected value in the /opt/output.txt file.</p>
<p dir="auto">Since we don’t want to print the text in stdout, we redirect tee‘s stdout to /dev/null.</p>
<ol start="7">
<li>Conclusion<br />
When we execute commands like “sudo command &gt; file_requires_root“, we may encounter the “Permission denied” error.</li>
</ol>
<p dir="auto">In this article, we’ve discussed this error, why it occurs, and several ways to solve the redirection problem.</p>
]]></description><link>http://an.forum.genostack.com/topic/324/sudo-重定向没有权限的几种解决办法</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/324/sudo-重定向没有权限的几种解决办法</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Wed, 16 Jun 2021 02:29:13 GMT</pubDate></item><item><title><![CDATA[cp mv终止恢复]]></title><description><![CDATA[<p dir="auto">diff --brief --recursive /ceph_disk3/siyida_327_sample/ /ceph_disk2/siyida_327_sample/</p>
<p dir="auto">可以diff检查下</p>
]]></description><link>http://an.forum.genostack.com/topic/323/cp-mv终止恢复</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/323/cp-mv终止恢复</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Tue, 15 Jun 2021 12:21:28 GMT</pubDate></item><item><title><![CDATA[VUE JS 报错Uncaught TypeError: Cannot assign to read only property &#x27;exports&#x27; of object &#x27;#&lt;Object&gt;&#x27;]]></title><description><![CDATA[<p dir="auto">导致报错原因：</p>
<p dir="auto"><strong>在webpack打包的时候，可以在js文件中混用require和export。但是不能混用import 以及module.exports。<br />
因为webpack 2中不允许混用import和module.exports,</strong><br />
根据线索更改报错<br />
将：</p>
<pre><code>module.exports={***}
</code></pre>
<p dir="auto">改为：</p>
<pre><code>export default {***};
</code></pre>
<p dir="auto">本次GenoStack项目中如何解决：<br />
1、原因在更新WDL版本之前一切正常（目标定位仅是WDL相关代码）<br />
2、然后在WDL依赖相关代码中排查出现<strong>module.exports</strong>的地方结果有一处确实有出现<br />
3、然后将出现<strong>module.exports</strong>更改为<strong>export default</strong><br />
4、重新打包，发布版本 问题解决</p>
]]></description><link>http://an.forum.genostack.com/topic/317/vue-js-报错uncaught-typeerror-cannot-assign-to-read-only-property-exports-of-object-object</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/317/vue-js-报错uncaught-typeerror-cannot-assign-to-read-only-property-exports-of-object-object</guid><dc:creator><![CDATA[zhangfanglin]]></dc:creator><pubDate>Tue, 08 Jun 2021 02:50:51 GMT</pubDate></item><item><title><![CDATA[查询linux命令行参数]]></title><description><![CDATA[<p dir="auto">命令行参数如果比较长 可以通过下面的文件查询<br />
cat /proc/&lt;pid&gt;/cmdline</p>
]]></description><link>http://an.forum.genostack.com/topic/273/查询linux命令行参数</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/273/查询linux命令行参数</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Fri, 02 Apr 2021 04:10:59 GMT</pubDate></item><item><title><![CDATA[修改时区]]></title><description><![CDATA[<p dir="auto">ubuntu 新安装的时候是UTC时间 修改到北京时间<br />
sudo timedatectl set-timezone Asia/Shanghai</p>
]]></description><link>http://an.forum.genostack.com/topic/258/修改时区</link><guid isPermaLink="true">http://an.forum.genostack.com/topic/258/修改时区</guid><dc:creator><![CDATA[anneng]]></dc:creator><pubDate>Thu, 25 Mar 2021 02:42:42 GMT</pubDate></item></channel></rss>