Segmentation fault on every command line in Ubuntu 16.04 - amazon-ec2

I have started getting segmentation fault (core dumped) error message on every command I enter on this EC2 instance. It is running Ubuntu 16.04. I was preparing the machine with Microsoft RDP via SSH tunnel and the last few steps I executed are below:
sudo sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo /etc/init.d/ssh restart
sudo passwd ubuntu
sudo apt install xrdp xfce4 xfce4-goodies tightvncserver
echo xfce4-session> /home/ubuntu/.xsession
sudo cp /home/ubuntu/.xsession /etc/skel
sudo sed -i '0,/-1/s//ask-1/' /etc/xrdp/xrdp.ini
Now, I am completely stuck. Almost every step produces the "segmentation fault(core dumped) " error. I rebooted the instance as well. What I can do? What are my options?
Thanks in advance.

Related

How to auto run commands when log on to Windows Subsystem for Linux

I have a Ubuntu 20.04 running within WSL 2 on a Windows 10 computer.
Every time I login to Ubuntu, I had to manually execute these four line by pasting it one by one in the Windows 10 Terminal.
sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME
sudo /etc/init.d/xrdp start
May I know if there is a way to skip this manual process?
You can use .bashrc file to execute commands whenever you open the terminal. It should be located at $HOME directory.
cd $HOME
nano .bashrc
place your commands at the end of the file, press ctl+x then y to save.

How to resume cfn-init commands after reboot in linux - redhat 7.4?

Is it possible to resume cfn-init in Redhat linux after reboot?
I have cfn-hup and cfn-auto-reloader setup correctly. And I have 'reboot' as one of the commands. All the commands run perfectly till this reboot command. And after the machine comes back from reboot it does not resume the rest of the cfn-init commands. In windows there's 'WaitAfterCompletion' option. Is there anything as such in linux? Just wondering if I'm missing something here. Thanks!!
Overall, in linux, you shouldn't have to reboot within a script unless it is something like a kernel update. That being said,
Don't think cfn-init has a direct way to resume operation after reboot in linux, but you can use this linux workaround (using a file to resume script) and call it in your user-data to resume your remaining portion of cfn-init post reboot.
https://unix.stackexchange.com/questions/145294/how-to-continue-a-script-after-it-reboots-the-machine
I usually handle linux reboot with user-data, this is an example with amazon linux 2 but it should work with redhat as well.
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
# update the system
yum update -y
# Check if kernel update requires a reboot, if yes it does reboot
needs-restarting -r ||
{
# reset user data so it processes again after reboot
rm -f /var/lib/cloud/instances/*/sem/config_scripts_user
echo rebooting ... $(date)
reboot
exit
}
# commands that run after reboot ...

I am unable to execute netcat command within docker bash terminal?

I am a beginner in docker . I have installed docker-ce in my ubuntu 18.04 machine using commandsudo apt install docker-ce
As part of a tutorial , I am trying to establish connection between containers by executing series of below commands.
Below command will turn on ports 1234/4321 to listen to traffic inside/outside of containers i'm going to use.
root#ghost-SVE9999CNS:/home/ghost# docker run --rm -ti -p 1234:1234 -p 4321:4321 --name echo-server ubuntu:18.04 bash
Now, I wanted to run netcat commands within docker bash terminal.
root#xxxyyyyzzzz12:/# nc -lp 1234 | nc -lp 4321
Once i inovke above command from my terminal.. Its giving errors "nc: command not found"
bash: nc: command not found
bash: nc: command not found
Later, I have done enough research and i never found any official docker solution for this problem.
Please could anyone help me out installing netcat within docker-ce.
I've tried commands like below.
apt-get install netstat
apt-get install nc
But, no luck.
nc is not installed by default on ubuntu:18.04 image, so you have to install it :
apt-get update && apt-get install -y netcat
apt-get update is necessary to first update list of packages (when the container is started, this list is empty). Once done, you can run nc -lp 1234 from the container.
To test all works as you expected, you can then :
run from a shell (on your host) something like telnet container_ip 1234 or telnet localhost 1234 (since ports have been forwarded)
type something
look at the container output to see what you typed in your host shell
It is not necessary to use ubuntu:18.04 to follow the tutorial, you can use ubuntu:14.04 for example, in which nc installed by default.
docker run --rm -ti -p 1234:1234 -p 4321:4321 --name echo-server ubuntu:14.04 bash

Sudo command not found (every sudo command is not working) (Mac)

I am trying to use 'Sudo' command for solving firewall problem.
so I typed 'sudo ufw allow 22' and 'sudo ufw allow 22/tcp' on my bash terminal.
but terminal keep saying "sudo command not found"
*:~ *$ sudo ufw allow 22
Password:
sudo: ufw: command not found
I tried to change path on bash_profile.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH
until 5 hours ago sudo command was working well and ssh too.
but after I changed /etc/network/interfaces information, all of sudden I couldn't use ssc and sudo.
Is there anyone can help me? It will be really appreciated.

Docker: bash terminal starts without prompt

I have a simple container that looks like this:
FROM devbox/rails3.2.1
RUN apt-get install -y -q libmysql-ruby libmysqlclient-dev
RUN apt-get install -y -q libqtwebkit-dev
EXPOSE 3000
CMD /bin/bash
where devbox/rails3.2.1 is a container I made that starts with 'FROM ubuntu' and installs Ruby on Rails. This is a running in a Vagrant Virtual Box VM using Ubuntu 12.04.3 LTS. When I run this using:
docker run -t -i -name myapp -p 3000:3000 -v /src/myapp:/src/myapp -link myappsql:myappsql devbox/myapp
The container starts, but my terminal shows a blank line with no prompt and typing doesn't do anything. If I run docker ps I can see that the container is running. Even stranger, If I open a second terminal and run 'docker attach myapp' I get a functioning terminal (though I have to press enter first) and if I switch back to my first terminal and type, the output appears in my second terminal!
Any help much appreciated.
That all sounds like expected functionality.
When doing the "docker run" command put the "/bin/bash" in it to immediately have the bash available to you without having to attach first.
docker run -t -i -name myapp -p 3000:3000 -v /src/myapp:/src/myapp -link myappsql:myappsql devbox/myapp /bin/bash

Resources