Remove folder with special character on it - linux

I accidentally created some folders with special characters. I already read the other posts in stackoverflow, but don't work. When I type the ls -la command I see
root#mycomputer:/myfolder# ls -la
drwxr-xr-x 3 root root 4096 feb 6 17:53 ,
drwxr-xr-x 70 root root 4096 feb 11 10:27 .
drwxr-xr-x 6 root root 4096 feb 11 09:16 ..
drwxr-xr-x 7 root root 4096 feb 9 22:45 (
drwxr-xr-x 3 root root 4096 feb 2 22:01 [
drwxr-xr-x 3 root root 4096 feb 6 08:11 $
drwxr-xr-x 3 root root 4096 feb 2 23:15 \
drwxr-xr-x 4 root root 4096 feb 8 10:34 &
drwxr-xr-x 5 root root 4096 feb 8 09:43 #
drwxr-xr-x 3 root root 4096 feb 6 14:41 +
drwxr-xr-x 6 root root 4096 feb 6 09:15 ?
drwxr-xr-x 4 root root 4096 feb 6 04:07 ?
drwxr-xr-x 5 root root 4096 feb 6 01:13 ?
drwxr-xr-x 3 root root 4096 feb 6 02:25 ?
drwxr-xr-x 5 root root 4096 feb 3 12:25 ?
drwxr-xr-x 4 root root 4096 feb 5 23:18 ?
I can't do anything with the ones pointed as question marks
I tried to type the command mv and then press tab and this is what I get
root#mycomputer:/myfolder# mv
,/ ▒/ 7/ h/
(/ ▒/ 8/ i/
[/ ▒/ 9/ j/
$/ ▒/
\/ ▒/
So apparently I can't rename them in order to delete them.
Any ideas?

What finally worked for me was one of the answers I found in this question:
rm all files except some
rm !(textfile.txt|backup.tar.gz|script.php|database.sql|info.txt)

If you don't need the other directories, you can just
rmdir ?
Or, use character class (supported e.g. in bash):
rmdir [^789hij] # removes all one-character directories except for 7, 9, etc.
You can also try mc or some other file manager.

Related

Jenkinsfile ,by using sh, says No such file or directory, but it exists

I'm studying jenkins, trying to package a maven project to a war, then move it to a previously started tomcat webapps directory(/opt/tomcat/latest/webpass), but it reports 'No such file or directory'.
Already find out what causes this, but don't know why. Jenkins don't use the same filesystem as original?
Here is my troubleshooting:
1、I create a directory in my linux server under / as temp20190808.
2、then in jenkins file add sh 'ls / -l', there is no temp20190808,also the description of each file in ls form show differenly compare with original(there are details under).
3、using jenkins file, i create a file under / as jenkinstmp2019, then ls / -l, it's there, but after rm the code of creating jenkinstmp2019, then rebuild, ls / -l, jenkinstmp2019 no longer there, so the jenkins file system is a onetime job?
Here are code elaboration on point 1,2:
in my linux server, using ls / -l, there is a tmp20190808 i just created.
total 24
lrwxrwxrwx. 1 root root 7 Jun 19 16:53 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Aug 1 04:55 boot
drwxr-xr-x. 17 root root 2860 Aug 7 02:48 dev
drwxr-xr-x. 86 root root 8192 Aug 7 20:52 etc
drwxr-xr-x. 4 root root 46 Jul 12 08:12 home
lrwxrwxrwx. 1 root root 7 Jun 19 16:53 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Jun 19 16:53 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 media
drwxr-xr-x. 2 root root 6 Apr 11 2018 mnt
drwxr-xr-x. 5 root root 53 Jul 23 08:11 opt
dr-xr-xr-x. 101 root root 0 Aug 7 02:47 proc
dr-xr-x---. 7 root root 215 Aug 6 02:53 root
drwxr-xr-x. 28 root root 920 Aug 8 02:03 run
lrwxrwxrwx. 1 root root 8 Jun 19 16:53 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Apr 11 2018 srv
dr-xr-xr-x. 13 root root 0 Aug 7 02:47 sys
drwxr-xr-x. 2 root root 6 Aug 8 01:50 temp1
drwxrwxrwt. 20 root root 4096 Aug 8 02:23 tmp
drwxr-xr-x. 2 root root 22 Aug 8 01:39 tmp20190808
drwxr-xr-x. 13 root root 155 Jun 19 16:53 usr
drwxr-xr-x. 20 root root 4096 Jul 12 07:36 var
in jenkins.
total 8448
drwxr-xr-x. 1 root root 19 Jun 9 2016 bin
drwxr-xr-x. 2 root root 6 May 30 2016 boot
-rw-------. 1 root root 8646656 Jun 9 2016 core
drwxr-xr-x. 5 root root 360 Aug 8 01:58 dev
drwxr-xr-x. 1 root root 66 Aug 8 01:58 etc
drwxr-xr-x. 2 root root 6 May 30 2016 home
drwxr-xr-x. 1 root root 45 Jun 9 2016 lib
drwxr-xr-x. 2 root root 34 Jun 8 2016 lib64
drwxr-xr-x. 2 root root 6 Jun 8 2016 media
drwxr-xr-x. 2 root root 6 Jun 8 2016 mnt
drwxr-xr-x. 2 root root 6 Jun 8 2016 opt
dr-xr-xr-x. 123 root root 0 Aug 8 01:58 proc
drwx------. 1 root root 33 Aug 8 01:58 root
drwxr-xr-x. 3 root root 30 Jun 8 2016 run
drwxr-xr-x. 2 root root 4096 Jun 8 2016 sbin
drwxr-xr-x. 2 root root 6 Jun 8 2016 srv
dr-xr-xr-x. 13 root root 0 Aug 7 02:47 sys
drwxrwxrwt. 1 root root 29 Jun 9 2016 tmp
drwxr-xr-x. 1 root root 30 Jun 10 2016 usr
drwxr-xr-x. 1 root root 41 Jun 9 2016 var
As you can see, it's like two totally different linux server, but it's the same one.
So i'm wondering whether jenkins create a temp virtual file server to execute it's job, so can't access to original file except it's own directory.
Find out the reason by myself.
The real cause is agent, i before used agent { docker { image 'XXX' } }, which makes jenkins run its job on docker image.Then i change it to agent any, so job will run on the server jenkins is deployed on.

`cd` to a folder in bash script not working: No such folder [duplicate]

This question already has answers here:
Why can't I change directories using "cd" in a script?
(33 answers)
'\r': command not found [duplicate]
(3 answers)
Closed 4 years ago.
This is my entire script. it is simply to avoid having to type it again and again
cd api
rails s -p 3001 -b 0.0.0.0
cd ..
When I am in the directory of the script and run cd api it works just fine. However when I run the script via ./start_server It does not work. Here is the output of ls -al:
mendel#DESKTOP-LIKG5E5:/mnt/c/Projects/chaverim-update$ ls -al
total 8
drwxrwxrwx 0 root root 512 Apr 13 12:32 .
drwxrwxrwx 0 root root 512 Apr 5 12:40 ..
drwxrwxrwx 0 root root 512 Apr 13 12:09 api
-rwxrwxrwx 1 root root 1237 Apr 5 12:40 boxfile.yml
drwxrwxrwx 0 root root 512 Apr 8 16:54 .bundle
drwxrwxrwx 0 root root 512 Apr 8 16:54 client
drwxrwxrwx 0 root root 512 Apr 13 12:09 .git
-rwxrwxrwx 1 root root 11 Apr 5 12:40 .gitignore
-rwxrwxrwx 1 root root 1097 Apr 5 12:40 LICENSE
drwxrwxrwx 0 root root 512 Apr 5 12:40 nginx
-rwxrwxrwx 1 root root 82 Apr 5 12:40 Procfile
-rwxrwxrwx 1 root root 67 Apr 5 12:40 README.md
-rwxrwxrwx 1 root root 188 Apr 5 12:40 run_tests
-rwxrwxrwx 1 root root 28 Apr 5 12:40 start_client
-rwxrwxrwx 1 root root 41 Apr 13 12:52 start_server
drwxrwxrwx 0 root root 512 Apr 8 16:54 vendor
As you can see there is a folder called api at the top and the start_server script is set to have execution permissions.

OSX Homebrew /usr/local permisions for node

I have installed homebrew without any problems.
The problem was to install node.. I got permission errors about /usr/local directory and symlinks.
So I did
sudo chown -R myuser /usr/local
then I istalled node without problems and then I did
sudo chown -R root /usr/local
I don't remember how was the owners in first place. I just followed some suggestions from stackoverflow to change the owner of /usr/local (a voice inside me says I did bad).
So when I run
brew doctor
I got some warnings and suggestions to chown some folders in /usr/local directory, so I did them. Then when I run
brew doctor
brew update
I get no warnings or errors anymore and looks fine (there was no updates to do after all).
My directories now looks like below. Can anyone confirm if is secure like that? How should be the owners in /usr/local ? Tt's okay to have it owned by my user as they say at github? Thanks.
myuser#iMac:/usr$ ls -la
total 8
drwxr-xr-x# 12 root wheel 408B Sep 30 23:52 ./
drwxr-xr-x 30 root wheel 1.1K Jan 23 17:51 ../
drwxr-xr-x 5 root wheel 170B Aug 23 03:51 X11/
lrwxr-xr-x 1 root wheel 3B Sep 30 23:43 X11R6# -> X11
drwxr-xr-x 3 root wheel 102B Aug 27 04:17 adic/
drwxr-xr-x 1055 root wheel 35K Jan 23 17:51 bin/
drwxr-xr-x 263 root wheel 8.7K Jan 23 17:52 lib/
drwxr-xr-x 186 root wheel 6.2K Jan 23 17:51 libexec/
drwxrwxr-x 22 root admin 748B Feb 7 12:28 local/
drwxr-xr-x 243 root wheel 8.1K Jan 23 17:51 sbin/
drwxr-xr-x 45 root wheel 1.5K Sep 30 23:43 share/
drwxr-xr-x 4 root wheel 136B Sep 17 09:03 standalone/
myuser#iMac:/usr$ cd local/
myuser#iMac:/usr/local$ ls -la
total 104
drwxrwxr-x 22 root admin 748B Feb 7 12:28 ./
drwxr-xr-x# 12 root wheel 408B Sep 30 23:52 ../
drwxr-xr-x 15 myuser admin 510B Feb 7 12:56 .git/
-rw-r--r-- 1 root admin 847B Feb 6 10:48 .gitignore
-rw-r--r-- 1 root admin 1.3K Feb 6 10:48 .travis.yml
-rw-r--r-- 1 root admin 291B Feb 6 10:48 .yardopts
-rw-r--r-- 1 root admin 3.1K Feb 6 10:48 CODEOFCONDUCT.md
-rw-r--r-- 1 root admin 2.5K Feb 6 10:48 CONTRIBUTING.md
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 Cellar/
-rw-r--r-- 1 root admin 1.2K Feb 6 10:48 LICENSE.txt
drwxr-xr-x 10 myuser admin 340B Feb 7 12:28 Library/
-rw-r--r-- 1 root admin 2.4K Feb 6 10:48 README.md
-rw-r--r-- 1 root admin 23K Feb 6 10:48 SUPPORTERS.md
drwxrwxr-x 9 root admin 306B Feb 7 12:28 bin/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 etc/
drwxr-xr-x 10 root wheel 340B Aug 3 2015 git/
drwxr-xr-x 20 root wheel 680B Dec 3 02:01 go/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 include/
drwxr-xr-x 4 myuser admin 136B Feb 7 12:28 lib/
drwxr-xr-x 3 root wheel 102B May 15 2015 n/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 opt/
drwxrwxr-x 5 root admin 170B Feb 7 12:28 share/
myuser#iMac:/usr/local$

how delete squiggly folder in sub directory

Im trying to delete folder, i dont know why it was can create..
i have already try rm -rf ~ , but it delete root folder
how to delete ~ (squiggly folder in sub directory) folder
below the path
# pwd
/root/data/xmpp-php/xmpphp
# ls -ltr
total 56
-rw-r----- 1 root root 1819 Jan 9 19:18 webclient_example.php
drwxr-xr-x 4 root root 4096 Jan 9 19:18 tests
-rw-r----- 1 root root 1647 Jan 9 19:18 cli_longrun_example_bosh.php
-rw-r----- 1 root root 2688 Jan 9 19:18 cli_longrun_example.php
drwxr-xr-x 3 root root 4096 Jan 9 19:18 XMPPHP
-rw-r----- 1 root root 1686 Jan 9 19:18 README
-rw-r----- 1 root root 18390 Jan 9 19:18 LICENSE
drwxr-xr-x 6 root root 4096 Jan 9 19:18 .svn
-rw-r----- 1 root root 637 Jan 10 00:41 ~ i want to delete this folder
-rw-r----- 1 root root 640 Jan 10 01:14 sendmessage_example.php
Try the following command:
cd /root/data/xmpp-php/xmpphp
rm -rf \~

CHROOT : Allowing outside access to chrooted users with mount bind

I have a chrooted user(username: clientdev) which I have jailed inside their home directory. This chroot directory is /home/clientdev/ which is owned by root.
Now I need this clientdev user to be able access the tomcat web application folder which is residing under /mnt/datadrive/tomcat/webapps.
What I have done is :
chroot the user with a public key of their own to the home
directory.
Create a folder under /home/clientdev called tomcat_ROOT and gave
the ownership to clientdev.
Now when I run the command :
mount -bind /mnn/datadrive/tomcat/webapps /home/clientdev/tomcat_ROOT
The folder disappears from the directory listing inside /home/clientdev if I login with clientdev. My root user can see it but now the desired user.
Any help would be greatly appreciated
Thanks in advance,
Peter
Output of ls -l /home/clientdev/tomcat_ROOT:
drwxr-xr-x. 6 root root 4096 Apr 11 15:07 .
drwxrwxr-x. 12 root root 4096 Apr 11 15:07 ..
drwxr-xr-x. 3 root root 4096 Apr 9 22:10 webapp1
drwxr-xr-x. 4 root root 4096 Mar 18 18:43 webapp2
drwxr-xr-x. 3 root root 4096 Apr 9 22:11 webapp3
drwxrwxr-x. 10 root root 4096 Apr 11 15:20 ROOT
Output of ls -l /home/clientdev/:
drwx------. 4 clientdev clientdev 4096 Apr 10 21:36 .
drwxr-xr-x. 7 root root 4096 Apr 10 22:07 ..
-rw-------. 1 clientdev clientdev 664 Apr 10 21:43 .bash_history
-rw-r--r--. 1 clientdev clientdev 18 Apr 23 2012 .bash_logout
-rw-r--r--. 1 clientdev clientdev 176 Apr 23 2012 .bash_profile
-rw-r--r--. 1 clientdev clientdev 124 Apr 23 2012 .bashrc
drwx------. 2 clientdev clientdev 4096 Apr 10 19:20 .ssh
drwxr-xr-x. 2 clientdev clientdev 4096 Apr 10 21:34 tomcat_ROOT

Resources